Skip to content

Commit 777d883

Browse files
committed
fix: append fragment cues when track mode is disabled
1 parent 5b791a9 commit 777d883

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,7 @@ declare namespace dashjs {
17321732
scheduleWhilePaused?: boolean
17331733
},
17341734
text?: {
1735+
appendFragmentedCuesWhenTrackModeDisabled?: boolean,
17351736
defaultEnabled?: boolean,
17361737
dispatchForManualRendering?: boolean,
17371738
extendSegmentedCues?: boolean,

src/core/Settings.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ import Events from './events/Events.js';
599599

600600
/**
601601
* @typedef {Object} Text
602+
* @property {boolean} [appendFragmentedCuesWhenTrackModeDisabled=true]
603+
* Whether fragment cues should be appended to the TextTrack when the track mode is set to disabled.
604+
* Fragment cues are fetched once. This ensures we don't miss them when the track mode is set to disabled.
602605
* @property {boolean} [defaultEnabled=true]
603606
* Enable/disable subtitle rendering by default.
604607
* @property {boolean} [dispatchForManualRendering=false]
@@ -1203,6 +1206,7 @@ function Settings() {
12031206
scheduleWhilePaused: true
12041207
},
12051208
text: {
1209+
appendFragmentedCuesWhenTrackModeDisabled: true,
12061210
defaultEnabled: true,
12071211
dispatchForManualRendering: false,
12081212
extendSegmentedCues: true,

src/streaming/text/TextTracks.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,12 @@ function TextTracks(config) {
549549
}
550550
}
551551
} else {
552-
if (track.mode !== Constants.TEXT_DISABLED) {
552+
const isFragmented = this.getCurrentTrackInfo()?.isFragmented;
553+
const appendFragmentedCuesWhenTrackModeDisabled = settings.get().streaming.text.appendFragmentedCuesWhenTrackModeDisabled;
554+
555+
// If disabled, add fragment cues as they'll be downloaded once.
556+
// If you miss them, they won't be downloaded again.
557+
if (track.mode !== Constants.TEXT_DISABLED || (appendFragmentedCuesWhenTrackModeDisabled && isFragmented)) {
553558
track.addCue(cue);
554559
}
555560
}

0 commit comments

Comments
 (0)