From 2f0d1adc815f89a5a6aef8ea26a0ae3917d566e5 Mon Sep 17 00:00:00 2001 From: "yuval.keidar" Date: Wed, 3 Feb 2021 09:35:44 +0200 Subject: [PATCH] fix: handle ima dai postroll Issue: Ima dai postroll doesn't work with another ad. Solution: handle playback ended and let ima dai to work with another ad --- src/common/controllers/ads-controller.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/common/controllers/ads-controller.js b/src/common/controllers/ads-controller.js index 86dd05d8d..1bd0e5cfb 100644 --- a/src/common/controllers/ads-controller.js +++ b/src/common/controllers/ads-controller.js @@ -341,22 +341,36 @@ class AdsController extends FakeEventTarget implements IAdsController { return controller.name === 'bumper'; } + _isIMA(controller: IAdsPluginController): boolean { + return controller.name === 'ima'; + } + + _isIMADAI(controller: IAdsPluginController): boolean { + return controller.name === 'imadai'; + } + _onEnded(): void { if (this._adIsLoading) { return; } const bumperCtrl = this._adsPluginControllers.find(controller => this._isBumper(controller)); - const adCtrl = this._adsPluginControllers.find(controller => !this._isBumper(controller)); + const imaCtrl = this._adsPluginControllers.find(controller => this._isIMA(controller)); + const imaDaiCtrl = this._adsPluginControllers.find(controller => this._isIMADAI(controller)); const bumperCompleted = bumperCtrl && typeof bumperCtrl.onPlaybackEnded === 'function' ? () => bumperCtrl.onPlaybackEnded() : () => Promise.resolve(); - const adCompleted = adCtrl && typeof adCtrl.onPlaybackEnded === 'function' ? () => adCtrl.onPlaybackEnded() : () => Promise.resolve(); + const imaCompleted = imaCtrl && typeof imaCtrl.onPlaybackEnded === 'function' ? () => imaCtrl.onPlaybackEnded() : () => Promise.resolve(); + const imaDaiCompleted = + imaDaiCtrl && typeof imaDaiCtrl.onPlaybackEnded === 'function' ? () => imaDaiCtrl.onPlaybackEnded() : () => Promise.resolve(); if (!(this._adBreaksLayout.includes(-1) || this._adBreaksLayout.includes('100%'))) { this._allAdsCompleted = true; } // $FlowFixMe - bumperCompleted().finally(() => { + imaDaiCompleted().finally(() => { // $FlowFixMe - adCompleted().finally(() => this._handleConfiguredPostroll()); + bumperCompleted().finally(() => { + // $FlowFixMe + imaCompleted().finally(() => this._handleConfiguredPostroll()); + }); }); }