Skip to content

Commit 19b511f

Browse files
bbertnicosang
authored andcommitted
add configuration value to enable keeping the samle instance of MediaKeys during MediaPlayer lifetime
1 parent 7c3d52b commit 19b511f

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

build/typings/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ declare namespace dashjs {
256256
setManifestUpdateRetryInterval(value: number): void;
257257
getManifestUpdateRetryInterval(): number;
258258
setSegmentOverlapToleranceTime(value: number): void;
259+
keepProtectionMediaKeys(value: boolean): void;
259260
}
260261

261262
export interface MediaPlayerFactory {

src/streaming/MediaPlayer.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,28 @@ function MediaPlayer() {
24842484
return thumbnailController.get(timeInPeriod);
24852485
}
24862486

2487+
/*
2488+
---------------------------------------------------------------------------
2489+
2490+
PROTECTION CONTROLLER MANAGEMENT
2491+
2492+
---------------------------------------------------------------------------
2493+
*/
2494+
2495+
/**
2496+
* Set the value for the ProtectionController and MediaKeys life cycle. If true, the
2497+
* ProtectionController and then created MediaKeys and MediaKeySessions will be preserved during
2498+
* the MediaPlayer lifetime.
2499+
*
2500+
* @param {boolean=} value - True or false flag.
2501+
*
2502+
* @memberof module:MediaPlayer
2503+
* @instance
2504+
*/
2505+
function keepProtectionMediaKeys(value) {
2506+
mediaPlayerModel.setKeepProtectionMediaKeys(value);
2507+
}
2508+
24872509
/*
24882510
---------------------------------------------------------------------------
24892511
@@ -3006,6 +3028,7 @@ function MediaPlayer() {
30063028
getUseDeadTimeLatencyForAbr: getUseDeadTimeLatencyForAbr,
30073029
setUseDeadTimeLatencyForAbr: setUseDeadTimeLatencyForAbr,
30083030
getThumbnail: getThumbnail,
3031+
keepProtectionMediaKeys: keepProtectionMediaKeys,
30093032
reset: reset
30103033
};
30113034

src/streaming/models/MediaPlayerModel.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ function MediaPlayerModel() {
114114
jumpGaps,
115115
smallGapLimit,
116116
lowLatencyEnabled,
117-
manifestUpdateRetryInterval;
117+
manifestUpdateRetryInterval,
118+
keepProtectionMediaKeys;
118119

119120
function setup() {
120121
UTCTimingSources = [];
@@ -533,6 +534,14 @@ function MediaPlayerModel() {
533534
return manifestUpdateRetryInterval;
534535
}
535536

537+
function setKeepProtectionMediaKeys(value) {
538+
keepProtectionMediaKeys = value;
539+
}
540+
541+
function getKeepProtectionMediaKeys() {
542+
return keepProtectionMediaKeys;
543+
}
544+
536545
function reset() {
537546
//TODO need to figure out what props to persist across sessions and which to reset if any.
538547
//setup();
@@ -613,6 +622,8 @@ function MediaPlayerModel() {
613622
setLowLatencyEnabled: setLowLatencyEnabled,
614623
setManifestUpdateRetryInterval: setManifestUpdateRetryInterval,
615624
getManifestUpdateRetryInterval: getManifestUpdateRetryInterval,
625+
setKeepProtectionMediaKeys: setKeepProtectionMediaKeys,
626+
getKeepProtectionMediaKeys: getKeepProtectionMediaKeys,
616627
reset: reset
617628
};
618629

0 commit comments

Comments
 (0)