Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: prevent event loop on preroll end #169

Merged
merged 2 commits into from
Mar 13, 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
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
Loading