Skip to content

Commit

Permalink
fix: prevent event loop on preroll end
Browse files Browse the repository at this point in the history
Remove the deferred start logic required to pass
yospace validation for 3.4.0 upgrade. Their new
sdk handles this case internally.
  • Loading branch information
martinstark committed Mar 6, 2024
1 parent f0507d4 commit 84104e8
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/ts/InternalBitmovinYospacePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CONNECTION_ERROR,
CONNECTION_TIMEOUT,
DEBUG_ALL,
DEBUG_VALIDATION,
MALFORMED_URL,
PlayerEvent as YsPlayerEvent,
ResourceType,
Expand Down Expand Up @@ -146,7 +147,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 +721,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 +851,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 +1111,10 @@ 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 84104e8

Please sign in to comment.