Skip to content

Commit

Permalink
Merge pull request #169 from bitmovin/fix-infinite-break-finished
Browse files Browse the repository at this point in the history
fix: prevent event loop on preroll end
  • Loading branch information
dweinber authored Mar 13, 2024
2 parents f0507d4 + 1a964c0 commit e2edfa0
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/ts/InternalBitmovinYospacePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
private startSent: boolean;

private lastTimeChangedTime = 0;
private deferredStart = false;

constructor(containerElement: HTMLElement, player: PlayerAPI, yospaceConfig: YospaceConfiguration = {}) {
this.yospaceConfig = yospaceConfig;
Expand Down Expand Up @@ -721,11 +720,6 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
}

this.player.setPlaybackSpeed(this.playbackSpeed);

if (this.deferredStart) {
this.session.onPlayerEvent(YsPlayerEvent.START, toMilliseconds(this.player.getCurrentTime()));
this.deferredStart = false;
}
};

private onAnalyticsFired = (event: BYSAnalyticsFiredEvent) => {
Expand Down Expand Up @@ -856,7 +850,6 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
this.cachedSeekTarget = null;
this.truexAdFree = undefined;
this.startSent = false;
this.deferredStart = false;
}

private handleQuartileEvent(adQuartileEventName: string): void {
Expand Down Expand Up @@ -1117,18 +1110,7 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {

const time = this.player.getCurrentTime();

this.deferredStart = true;

// immediately force through a playhead update in order
// to give yospace a chance to detect prerolls
this.session.onPlayheadUpdate(toMilliseconds(time));

// only trigger YsPlayerEvent.START when content starts rolling
// either here, or after the preroll ends
if (!this.isAdActive()) {
this.session.onPlayerEvent(YsPlayerEvent.START, toMilliseconds(time));
this.deferredStart = false;
}
this.session.onPlayerEvent(YsPlayerEvent.START, toMilliseconds(time));
} else {
Logger.log('[BitmovinYospacePlayer] - sending YospaceAdManagement.PlayerEvent.RESUME');
this.session.onPlayerEvent(YsPlayerEvent.RESUME, toMilliseconds(this.player.getCurrentTime()));
Expand Down

0 comments on commit e2edfa0

Please sign in to comment.