Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-10967): handle ima dai postroll #409

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/common/controllers/ads-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
});
}

Expand Down