UNPKG

unified-video-framework

Version:

Cross-platform video player framework supporting iOS, Android, Web, Smart TVs (Samsung/LG), Roku, and more

35 lines 1.24 kB
import { KEY_SYSTEMS } from '../types/DRMTypes.js'; export class BrowserDetector { static async detectCapabilities() { const caps = { widevine: false, fairplay: false, playready: false }; if (typeof navigator === 'undefined' || !navigator.requestMediaKeySystemAccess) { return caps; } const basicConfig = [{ initDataTypes: ['cenc'], videoCapabilities: [{ contentType: 'video/mp4; codecs="avc1.42E01E"' }], }]; const checks = [ ['widevine', KEY_SYSTEMS.WIDEVINE], ['playready', KEY_SYSTEMS.PLAYREADY], ]; for (const [key, system] of checks) { try { await navigator.requestMediaKeySystemAccess(system, basicConfig); caps[key] = true; } catch { } } if (typeof window.WebKitMediaKeys !== 'undefined') { caps.fairplay = true; } return caps; } static isSafari() { if (typeof navigator === 'undefined') return false; const ua = navigator.userAgent; return /Safari/.test(ua) && !/Chrome/.test(ua); } } //# sourceMappingURL=BrowserDetector.js.map