From 79cadba0e70310e68db48a9650468c9b10986efe Mon Sep 17 00:00:00 2001 From: Agajan Jumakuliyev Date: Sun, 22 Sep 2024 17:41:49 -0700 Subject: [PATCH] Update index.js To avoid application crash, don't add encryptionScheme field to some platforms. --- index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6b0bc37..4ea9833 100644 --- a/index.js +++ b/index.js @@ -460,13 +460,19 @@ class McEncryptionSchemePolyfill { const mediaCapKeySystemConfig = decodingConfig.keySystemConfiguration; const audioCapabilities = []; const videoCapabilities = []; + const isLegacyPlatform = /PlayStation 4|Sky_STB/i.test(navigator.userAgent); if (mediaCapKeySystemConfig.audio) { const capability = { robustness: mediaCapKeySystemConfig.audio.robustness || '', contentType: decodingConfig.audio.contentType, - encryptionScheme: mediaCapKeySystemConfig.audio.encryptionScheme, }; + // Exclude encryptionScheme for legacy platforms to prevent crashes + if (!isLegacyPlatform) { + capability.encryptionScheme = + mediaCapKeySystemConfig.audio.encryptionScheme; + } + audioCapabilities.push(capability); } @@ -474,8 +480,13 @@ class McEncryptionSchemePolyfill { const capability = { robustness: mediaCapKeySystemConfig.video.robustness || '', contentType: decodingConfig.video.contentType, - encryptionScheme: mediaCapKeySystemConfig.video.encryptionScheme, }; + // Exclude encryptionScheme for legacy platforms to prevent crashes + if (!isLegacyPlatform) { + capability.encryptionScheme = + mediaCapKeySystemConfig.video.encryptionScheme; + } + videoCapabilities.push(capability); }