Skip to content

Commit

Permalink
Trigger INTERSTITIALS_PRIMARY_RESUMED after ending interstitial with …
Browse files Browse the repository at this point in the history
…CUE ONCE

Resolves #6911
  • Loading branch information
robwalch committed Dec 19, 2024
1 parent ace5c57 commit f4eddb8
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/controller/interstitials-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,6 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`,
}
this.log(`setSchedulePosition ${index}, ${assetListIndex}`);
const scheduledItem = index >= 0 ? scheduleItems[index] : null;
const media = this.primaryMedia;
// Cleanup current item / asset
const currentItem = this.playingItem;
const playingLastItem = this.playingLastItem;
Expand Down Expand Up @@ -1011,15 +1010,40 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`,
// Exiting an Interstitial
this.clearInterstitial(interstitial, scheduledItem);
if (interstitial.cue.once) {
// Remove interstitial with CUE attribute value of ONCE after it has played
this.updateSchedule();
if (scheduledItem) {
const items = this.schedule.items;
if (scheduledItem && items) {
const updatedIndex = this.schedule.findItemIndex(scheduledItem);
this.setSchedulePosition(updatedIndex, assetListIndex);
this.advanceSchedule(
updatedIndex,
items,
assetListIndex,
currentItem,
playingLastItem,
);
}
return;
}
}
}
this.advanceSchedule(
index,
scheduleItems,
assetListIndex,
currentItem,
playingLastItem,
);
}
private advanceSchedule(
index: number,
scheduleItems: InterstitialScheduleItem[],
assetListIndex: number | undefined,
currentItem: InterstitialScheduleItem | null,
playedLastItem: boolean,
) {
const scheduledItem = index >= 0 ? scheduleItems[index] : null;
const media = this.primaryMedia;
// Cleanup out of range Interstitials
const playerQueue = this.playerQueue;
if (playerQueue.length) {
Expand Down Expand Up @@ -1139,7 +1163,7 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`,
if (this.shouldPlay) {
playWithCatch(this.hls.media);
}
} else if (playingLastItem && this.isInterstitial(currentItem)) {
} else if (playedLastItem && this.isInterstitial(currentItem)) {
// Maintain playingItem state at end of schedule (setSchedulePosition(-1) called to end program)
// this allows onSeeking handler to update schedule position
this.playingItem = currentItem;
Expand Down

0 comments on commit f4eddb8

Please sign in to comment.