From 04aba845d2a2d7d222b0d8dfa24aa4155724559d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Tue, 21 May 2024 10:28:11 +0200 Subject: [PATCH] fix: Fix access to null properties --- index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6ccb995..0e73eaa 100644 --- a/index.js +++ b/index.js @@ -187,10 +187,18 @@ class EmeEncryptionSchemePolyfill { // Wrap the MKSA object in ours to provide the missing field in the // returned configuration. - const videoScheme = filteredSupportedConfigurations[0] - .videoCapabilities[0].encryptionScheme; - const audioScheme = filteredSupportedConfigurations[0] - .audioCapabilities[0].encryptionScheme; + let videoScheme = null; + let audioScheme = null; + if (filteredSupportedConfigurations[0]) { + if (filteredSupportedConfigurations[0].videoCapabilities) { + videoScheme = filteredSupportedConfigurations[0] + .videoCapabilities[0].encryptionScheme; + } + if (filteredSupportedConfigurations[0].audioCapabilities) { + audioScheme = filteredSupportedConfigurations[0] + .audioCapabilities[0].encryptionScheme; + } + } return new EmeEncryptionSchemePolyfillMediaKeySystemAccess( mediaKeySystemAccess, videoScheme, audioScheme); }