diff --git a/.changeset/lovely-queens-boil.md b/.changeset/lovely-queens-boil.md new file mode 100644 index 00000000..7621068d --- /dev/null +++ b/.changeset/lovely-queens-boil.md @@ -0,0 +1,5 @@ +--- +"@theoplayer/yospace-connector-web": minor +--- + +Create ad break from advert start, if missing diff --git a/yospace/src/integration/YospaceAdHandler.ts b/yospace/src/integration/YospaceAdHandler.ts index 49fae354..aae8389c 100644 --- a/yospace/src/integration/YospaceAdHandler.ts +++ b/yospace/src/integration/YospaceAdHandler.ts @@ -144,6 +144,13 @@ export class YospaceAdHandler { this.advertStartListener = undefined; } + if (this.currentAdBreak === undefined) { + const missingAdBreak = advert.broker.getAdBreakForAdvert(advert); + if (missingAdBreak !== undefined) { + this.currentAdBreak = this.getOrCreateAdBreak(missingAdBreak, true); + } + } + const ad = this.ads.get(advert); if (ad !== undefined) { this.currentAd = ad; diff --git a/yospace/src/yospace/AdBreak.ts b/yospace/src/yospace/AdBreak.ts index 2bb7cc00..f19c7b05 100644 --- a/yospace/src/yospace/AdBreak.ts +++ b/yospace/src/yospace/AdBreak.ts @@ -1,3 +1,5 @@ +import { YospaceSessionManager } from "./YospaceSessionManager"; + export enum ResourceType { STATIC, HTML, @@ -75,6 +77,7 @@ export interface AdvertEventHandler { export interface Advert extends AdvertEventHandler { addMacroSubstitution(key: string, value: string): void; + broker: YospaceSessionManager; getAdType(): string; getAdVerifications(): AdVerification[]; getCompanionAdsByType(type: ResourceType): CompanionCreative[]; diff --git a/yospace/src/yospace/YospaceSessionManager.ts b/yospace/src/yospace/YospaceSessionManager.ts index 4a5f29cc..974da38b 100644 --- a/yospace/src/yospace/YospaceSessionManager.ts +++ b/yospace/src/yospace/YospaceSessionManager.ts @@ -1,6 +1,7 @@ import { PlayerEvent } from './PlayerEvent'; import { TimedMetadata } from './TimedMetadata'; import { AnalyticEventObserver } from './AnalyticEventObserver'; +import { AdVert, AdBreak } from './AdBreak'; export enum ResultCode { CONNECTION_ERROR = -1, @@ -28,6 +29,8 @@ export type YospaceSessionManagerCreator = { }; export interface YospaceSession { + getAdBreakForAdvert(advert: AdVert): AdBreak | undefined; + getPlaybackMode(): PlaybackMode; getPlaybackUrl(): string;