Skip to content

Commit

Permalink
fix: Fix access to null properties
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed May 21, 2024
1 parent b149af7 commit 04aba84
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 04aba84

Please sign in to comment.