From d5ecb15259ba6cd23a5b42a63c882ccb29469773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 21 Nov 2024 12:09:58 +0100 Subject: [PATCH] fix: Fix CBCS support in recent WebOS (#81) Related to https://github.com/shaka-project/shaka-player/issues/7477 --- index.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/index.js b/index.js index 6b0bc37..342eef1 100644 --- a/index.js +++ b/index.js @@ -654,8 +654,10 @@ function checkSupportedScheme(scheme, supportedScheme) { if (scheme == 'cbcs' || scheme == 'cbcs-1-9') { if (EncryptionSchemePolyfills.isRecentFirefox || + EncryptionSchemePolyfills.isRecentWebOS || EncryptionSchemePolyfills.isChromecast) { // Firefox >= 100 supports CBCS, but doesn't support queries yet. + // WebOS >= 6 supports CBCS, but doesn't support queries yet. // Older Chromecast devices are assumed to support CBCS as well. return true; } @@ -718,6 +720,23 @@ EncryptionSchemePolyfills.isChromecast = EncryptionSchemePolyfills.isRecentFirefox = parseInt(navigator.userAgent.split('Firefox/').pop(), 10) >= 100; +/** + * @const {boolean} + */ +EncryptionSchemePolyfills.isRecentWebOS = (() => { + const userAgent = navigator.userAgent || ''; + const isWebOS = userAgent.includes('Web0S'); + if (!isWebOS) { + return false; + } + const chromeVersionMatch = userAgent.match(/Chrome\/(\d+)/); + if (!chromeVersionMatch) { + return false; + } + const chromeVersion = parseInt(chromeVersionMatch[1], 10); + return chromeVersion >= 79; +})(); + // Support for CommonJS and AMD module formats. /** @suppress {undefinedVars} */ (() => {