Skip to content

Commit 1825266

Browse files
authored
fix: Fix playback with Apple Media Keys polyfill detection (#7958)
1 parent a38a810 commit 1825266

File tree

5 files changed

+7
-22
lines changed

5 files changed

+7
-22
lines changed

lib/dash/content_protection.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ shaka.dash.ContentProtection = class {
203203
* @return {string}
204204
*/
205205
static getFairPlayLicenseUrl(element) {
206-
if (shaka.util.Platform.isMediaKeysPolyfilled()) {
206+
if (shaka.util.Platform.isMediaKeysPolyfilled('apple')) {
207207
throw new shaka.util.Error(
208208
shaka.util.Error.Severity.CRITICAL,
209209
shaka.util.Error.Category.MANIFEST,

lib/hls/hls_parser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4767,7 +4767,7 @@ shaka.hls.HlsParser = class {
47674767
shaka.util.Error.Code.HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED);
47684768
}
47694769

4770-
if (shaka.util.Platform.isMediaKeysPolyfilled()) {
4770+
if (shaka.util.Platform.isMediaKeysPolyfilled('apple')) {
47714771
throw new shaka.util.Error(
47724772
shaka.util.Error.Severity.CRITICAL,
47734773
shaka.util.Error.Category.MANIFEST,
@@ -4957,7 +4957,7 @@ shaka.hls.HlsParser = class {
49574957
shaka.util.Error.Code.HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED);
49584958
}
49594959

4960-
if (shaka.util.Platform.isMediaKeysPolyfilled()) {
4960+
if (shaka.util.Platform.isMediaKeysPolyfilled('apple')) {
49614961
throw new shaka.util.Error(
49624962
shaka.util.Error.Severity.CRITICAL,
49634963
shaka.util.Error.Category.MANIFEST,

lib/util/platform.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -705,16 +705,13 @@ shaka.util.Platform = class {
705705
}
706706

707707
/**
708-
* Returns true if MediaKeys is polyfilled
708+
* Returns true if MediaKeys is polyfilled by the specified polyfill.
709709
*
710-
* @param {string=} polyfillType
710+
* @param {string} polyfillType
711711
* @return {boolean}
712712
*/
713713
static isMediaKeysPolyfilled(polyfillType) {
714-
if (polyfillType) {
715-
return polyfillType === window.shakaMediaKeysPolyfill;
716-
}
717-
return !!window.shakaMediaKeysPolyfill;
714+
return polyfillType === window.shakaMediaKeysPolyfill;
718715
}
719716

720717

lib/util/player_configuration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ shaka.util.PlayerConfiguration = class {
7575
persistentSessionOnlinePlayback: false,
7676
persistentSessionsMetadata: [],
7777
initDataTransform: (initData, initDataType, drmInfo) => {
78-
if (shaka.util.Platform.isMediaKeysPolyfilled() &&
78+
if (shaka.util.Platform.isMediaKeysPolyfilled('apple') &&
7979
initDataType == 'skd') {
8080
const cert = drmInfo.serverCertificate;
8181
const contentId =

test/util/platform_unit.js

-12
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,6 @@ describe('Platform', () => {
134134
window.shakaMediaKeysPolyfill = shakaMediaKeysPolyfill;
135135
});
136136

137-
it('should return true if media keys are polyfilled', () => {
138-
window.shakaMediaKeysPolyfill = 'webkit';
139-
const result = shaka.util.Platform.isMediaKeysPolyfilled();
140-
expect(result).toBe(true);
141-
});
142-
143-
it('should return false if media keys are not polyfilled', () => {
144-
window.shakaMediaKeysPolyfill = '';
145-
const result = shaka.util.Platform.isMediaKeysPolyfilled();
146-
expect(result).toBe(false);
147-
});
148-
149137
it('should return true with a matching polyfill type', () => {
150138
window.shakaMediaKeysPolyfill = 'webkit';
151139
const result = shaka.util.Platform.isMediaKeysPolyfilled('webkit');

0 commit comments

Comments
 (0)