Skip to content

Commit

Permalink
Don't resume playback on interstitial transition after player is paused
Browse files Browse the repository at this point in the history
  • Loading branch information
robwalch committed Dec 11, 2024
1 parent 3ab014a commit 6357c16
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/controller/interstitials-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export default class InterstitialsController
// @ts-ignore
this.assetListLoader = null;
// @ts-ignore
this.onPlay = this.onSeeking = this.onTimeupdate = null;
this.onPlay = this.onPause = this.onSeeking = this.onTimeupdate = null;
// @ts-ignore
this.onScheduleUpdate = null;
}
Expand All @@ -232,6 +232,7 @@ export default class InterstitialsController

private removeMediaListeners(media: HTMLMediaElement) {
media.removeEventListener('play', this.onPlay);
media.removeEventListener('pause', this.onPause);
media.removeEventListener('seeking', this.onSeeking);
media.removeEventListener('timeupdate', this.onTimeupdate);
}
Expand All @@ -245,6 +246,7 @@ export default class InterstitialsController
media.addEventListener('seeking', this.onSeeking);
media.addEventListener('timeupdate', this.onTimeupdate);
media.addEventListener('play', this.onPlay);
media.addEventListener('pause', this.onPause);
}

private onMediaAttached(
Expand Down Expand Up @@ -763,6 +765,10 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`,
this.shouldPlay = true;
};

private onPause = () => {
this.shouldPlay = false;
};

private onSeeking = () => {
const currentTime = this.currentTime;
if (currentTime === undefined || this.playbackDisabled) {
Expand Down

0 comments on commit 6357c16

Please sign in to comment.