From 1b2839f092eb17986eefcd64fe800a7409bed3ef Mon Sep 17 00:00:00 2001 From: Ruben Baetens Date: Thu, 24 Oct 2024 11:22:44 +0200 Subject: [PATCH 1/5] Create AdBreak if nonexistent when advert starts --- yospace/src/integration/YospaceAdHandler.ts | 4 ++++ yospace/src/yospace/AdBreak.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/yospace/src/integration/YospaceAdHandler.ts b/yospace/src/integration/YospaceAdHandler.ts index 49fae354..13ff484e 100644 --- a/yospace/src/integration/YospaceAdHandler.ts +++ b/yospace/src/integration/YospaceAdHandler.ts @@ -144,6 +144,10 @@ export class YospaceAdHandler { this.advertStartListener = undefined; } + if (this.currentAdBreak === undefined) { + this.currentAdBreak = this.getOrCreateAdBreak(advert.broker.currentAdBreak, 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..d2f085ec 100644 --- a/yospace/src/yospace/AdBreak.ts +++ b/yospace/src/yospace/AdBreak.ts @@ -93,6 +93,7 @@ export interface Advert extends AdvertEventHandler { isActive(): boolean; isFiller(): boolean; isNonLinear(): boolean; + broker: any; } export type { Advert as AdVert }; From 4db048bc35fa4850abfa1cda0c4151fae823e3aa Mon Sep 17 00:00:00 2001 From: Ruben Baetens Date: Thu, 24 Oct 2024 13:34:19 +0200 Subject: [PATCH 2/5] Added missing properties for fetching AdBreak from Advert --- yospace/src/yospace/AdBreak.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/yospace/src/yospace/AdBreak.ts b/yospace/src/yospace/AdBreak.ts index d2f085ec..33602ae4 100644 --- a/yospace/src/yospace/AdBreak.ts +++ b/yospace/src/yospace/AdBreak.ts @@ -75,6 +75,7 @@ export interface AdvertEventHandler { export interface Advert extends AdvertEventHandler { addMacroSubstitution(key: string, value: string): void; + broker: Broker; getAdType(): string; getAdVerifications(): AdVerification[]; getCompanionAdsByType(type: ResourceType): CompanionCreative[]; @@ -93,7 +94,10 @@ export interface Advert extends AdvertEventHandler { isActive(): boolean; isFiller(): boolean; isNonLinear(): boolean; - broker: any; +} + +export interface Broker { + getAdBreakForAdvert(advert: Advert): AdBreak | undefined; } export type { Advert as AdVert }; From 9546dc12e641abb08a4eaf35493a6e681693ad39 Mon Sep 17 00:00:00 2001 From: Ruben Baetens Date: Thu, 24 Oct 2024 13:35:13 +0200 Subject: [PATCH 3/5] Rework adding missing AdBreak to use updated type definition --- yospace/src/integration/YospaceAdHandler.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yospace/src/integration/YospaceAdHandler.ts b/yospace/src/integration/YospaceAdHandler.ts index 13ff484e..aae8389c 100644 --- a/yospace/src/integration/YospaceAdHandler.ts +++ b/yospace/src/integration/YospaceAdHandler.ts @@ -145,7 +145,10 @@ export class YospaceAdHandler { } if (this.currentAdBreak === undefined) { - this.currentAdBreak = this.getOrCreateAdBreak(advert.broker.currentAdBreak, true); + const missingAdBreak = advert.broker.getAdBreakForAdvert(advert); + if (missingAdBreak !== undefined) { + this.currentAdBreak = this.getOrCreateAdBreak(missingAdBreak, true); + } } const ad = this.ads.get(advert); From d46a83e4fbb2ca6b36e11aba84513a9b281b9bf3 Mon Sep 17 00:00:00 2001 From: Ruben Baetens Date: Thu, 24 Oct 2024 13:47:43 +0200 Subject: [PATCH 4/5] Remove Broker as this is the same as the SessionManager --- yospace/src/yospace/AdBreak.ts | 8 +++----- yospace/src/yospace/YospaceSessionManager.ts | 3 +++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/yospace/src/yospace/AdBreak.ts b/yospace/src/yospace/AdBreak.ts index 33602ae4..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,7 +77,7 @@ export interface AdvertEventHandler { export interface Advert extends AdvertEventHandler { addMacroSubstitution(key: string, value: string): void; - broker: Broker; + broker: YospaceSessionManager; getAdType(): string; getAdVerifications(): AdVerification[]; getCompanionAdsByType(type: ResourceType): CompanionCreative[]; @@ -96,10 +98,6 @@ export interface Advert extends AdvertEventHandler { isNonLinear(): boolean; } -export interface Broker { - getAdBreakForAdvert(advert: Advert): AdBreak | undefined; -} - export type { Advert as AdVert }; export interface VASTProperty { 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; From 2ab9fe2acb978eefbd63524a5685d840cfc5d975 Mon Sep 17 00:00:00 2001 From: rbnbtns Date: Fri, 25 Oct 2024 11:37:27 +0200 Subject: [PATCH 5/5] Added changeset --- .changeset/lovely-queens-boil.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lovely-queens-boil.md 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