Skip to content

Commit

Permalink
feat: make ad break check offset configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
martinstark committed Mar 21, 2024
1 parent 9d75e71 commit 0fc1dc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/ts/BitmovinYospacePlayerAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
5 changes: 3 additions & 2 deletions src/ts/InternalBitmovinYospacePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
Expand Down

0 comments on commit 0fc1dc7

Please sign in to comment.