From 0fc1dc753a4f6a74873d28478dc9fb02f86c6532 Mon Sep 17 00:00:00 2001 From: Martin <901824+martinstark@users.noreply.github.com> Date: Thu, 21 Mar 2024 15:11:24 +0100 Subject: [PATCH] feat: make ad break check offset configurable --- src/ts/BitmovinYospacePlayerAPI.ts | 3 +++ src/ts/InternalBitmovinYospacePlayer.ts | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ts/BitmovinYospacePlayerAPI.ts b/src/ts/BitmovinYospacePlayerAPI.ts index 032c0b91..ba715fd4 100644 --- a/src/ts/BitmovinYospacePlayerAPI.ts +++ b/src/ts/BitmovinYospacePlayerAPI.ts @@ -264,7 +264,10 @@ export interface AdImmunityEndedEvent extends YospaceEventBase { /** * @description Ad Immunity Configuration Object * @property duration - a number indicating the duration of the ad immunity period. 0 disables the feature. + * @property adBreakCheckOffset - a number indicating how far ahead ad immunity should look for ad breaks + * to skip past, in order to mitigate ad frames being displayed before they have time to be seeked past. */ export interface AdImmunityConfig { duration: number; + adBreakCheckOffset?: number; } diff --git a/src/ts/InternalBitmovinYospacePlayer.ts b/src/ts/InternalBitmovinYospacePlayer.ts index daf867f6..5b34bf35 100644 --- a/src/ts/InternalBitmovinYospacePlayer.ts +++ b/src/ts/InternalBitmovinYospacePlayer.ts @@ -151,8 +151,9 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI { private startSent: boolean; private lastTimeChangedTime = 0; - private adImmunityConfig = { + private adImmunityConfig: AdImmunityConfig = { duration: 0, // 0 duration = disabled + adBreakCheckOffset: 200, }; private adImmune = false; private adImmunityCountDown: number | null = null; @@ -1228,7 +1229,7 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI { // the offset of 500ms is an attempt to prevent the // first few frames of an ad playing before the seek // past the break has time to propagate - const adBreakCheckOffset = 500; + const adBreakCheckOffset = this.adImmunityConfig.adBreakCheckOffset; const upcomingAdBreak: AdBreak | null = this.session.getAdBreakForPlayhead( toMilliseconds(event.time) + adBreakCheckOffset );