Skip to content

Commit

Permalink
fix(FEC-11056): No replay button once ima postroll finished when imad…
Browse files Browse the repository at this point in the history
…ai configured (#61)

issue: The default state of imadai is `IDLE` so it's not "done" even it not active at all
Solution:  Change the default state to `DONE` and move to `IDLE` only once there are ads
also get rid `LOADED` and `LOADING` states as these states are about the ad,
and irrelevant in imadai at all as the ad is not loaded
  • Loading branch information
yairans authored Mar 7, 2021
1 parent 0b9e191 commit 53bbd94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/ima-dai-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* @type {Object}
*/
const ImaDAIState: {[state: string]: string} = {
LOADING: 'loading',
LOADED: 'loaded',
PLAYING: 'playing',
PAUSED: 'paused',
IDLE: 'idle',
Expand Down
7 changes: 4 additions & 3 deletions src/ima-dai.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class ImaDAI extends BasePlugin implements IAdsControllerProvider, IEngineDecora
return new Promise((resolve, reject) => {
return this._loadPromise
.then(() => {
this._state = ImaDAIState.LOADING;
this._resolveLoad = resolve;
this._rejectLoad = reject;
this._initStreamManager();
Expand Down Expand Up @@ -328,7 +327,7 @@ class ImaDAI extends BasePlugin implements IAdsControllerProvider, IEngineDecora
}

_initMembers(): void {
this._state = ImaDAIState.IDLE;
this._state = ImaDAIState.DONE;
this._cuePoints = [];
this._adBreak = false;
this._savedSeekTime = null;
Expand Down Expand Up @@ -404,6 +403,9 @@ class ImaDAI extends BasePlugin implements IAdsControllerProvider, IEngineDecora
}
});
this._dispatchAdEvent(EventType.AD_MANIFEST_LOADED, {adBreaksPosition: adBreaksPosition});
if (adBreaksPosition.length > 0) {
this._state = ImaDAIState.IDLE;
}
if (this.player.ui.hasManager('timeline') && this.config.showAdBreakCuePoint) {
adBreaksPosition.forEach(position => {
this.player.ui.getManager('timeline').addCuePoint({
Expand Down Expand Up @@ -459,7 +461,6 @@ class ImaDAI extends BasePlugin implements IAdsControllerProvider, IEngineDecora

_onLoaded(event: Object): void {
const streamData = event.getStreamData();
this._state = ImaDAIState.LOADED;
this.logger.debug('Stream loaded', streamData);
this._resolveLoad(streamData.url);
}
Expand Down

0 comments on commit 53bbd94

Please sign in to comment.