Skip to content

Commit 3c60254

Browse files
authored
fix: Add new crossBoundaryStrategy for Apple browsers (#8345)
Related to #8335
1 parent 6d5cdb6 commit 3c60254

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

demo/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ shakaDemo.Config = class {
598598
'KEEP': 'Keep',
599599
'RESET': 'Reset',
600600
'RESET_TO_ENCRYPTED': 'Reset to encrypted',
601+
'RESET_ON_ENCRYPTION_CHANGE': 'Reset on encryption change',
601602
};
602603

603604
this.addBoolInput_('Start At Segment Boundary',

lib/config/cross_boundary_strategy.js

+6
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ shaka.config.CrossBoundaryStrategy = {
2424
* boundary to an encrypted boundary.
2525
*/
2626
'RESET_TO_ENCRYPTED': 'reset_to_encrypted',
27+
/**
28+
* Reset MediaSource, when transitioning from a plain
29+
* boundary to an encrypted boundary or from an encrypted
30+
* boundary to a plain boundary.
31+
*/
32+
'RESET_ON_ENCRYPTION_CHANGE': 'RESET_ON_ENCRYPTION_CHANGE',
2733
};

lib/media/streaming_engine.js

+8
Original file line numberDiff line numberDiff line change
@@ -3117,6 +3117,14 @@ shaka.media.StreamingEngine = class {
31173117
this.config_.crossBoundaryStrategy = CrossBoundaryStrategy.KEEP;
31183118
}
31193119
}
3120+
if (this.config_.crossBoundaryStrategy ===
3121+
CrossBoundaryStrategy.RESET_ON_ENCRYPTION_CHANGE) {
3122+
if (lastInitRef.encrypted == initRef.encrypted) {
3123+
// We're crossing a plain to plain boundary or we're crossing a
3124+
// encrypted to encrypted boundary, allow the reference.
3125+
discard = false;
3126+
}
3127+
}
31203128
// If discarded & seeked across a boundary, reset MediaSource.
31213129
if (discard && mediaState.seeked) {
31223130
shaka.log.debug(logPrefix, 'reset mediaSource',

lib/util/player_configuration.js

+5
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ shaka.util.PlayerConfiguration = class {
311311
shaka.config.CrossBoundaryStrategy.RESET_TO_ENCRYPTED;
312312
}
313313

314+
if (shaka.util.Platform.isApple()) {
315+
streaming.crossBoundaryStrategy =
316+
shaka.config.CrossBoundaryStrategy.RESET_ON_ENCRYPTION_CHANGE;
317+
}
318+
314319
const networking = {
315320
forceHTTP: false,
316321
forceHTTPS: false,

0 commit comments

Comments
 (0)