Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Trigger INTERSTITIALS_PRIMARY_RESUMED after ending interstitial with CUE ONCE #6915

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading