Skip to content

Commit

Permalink
fix(FEC-10471): adPosition getter returns preroll for mid and post ro…
Browse files Browse the repository at this point in the history
…lls (#56)

Use `youbora.Constants` instead of `youbora.Adapter.AdPosition`
Also bind to `AD_BREAk_START`

Solves FEC-10471
  • Loading branch information
jesuslc91 authored Sep 8, 2020
1 parent 16885e4 commit b70634b
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/adapter/ads/nativeads.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ let NativeAdsAdapter = youbora.Adapter.extend({

/** @returns {String} - current ad position (only ads) */
getPosition: function () {
let returnValue = youbora.Adapter.AdPosition.MIDROLL;
let returnValue = youbora.Constants.AdPosition.Midroll;
switch (this.adPosition) {
case 'preroll':
returnValue = youbora.Adapter.AdPosition.PREROLL;
returnValue = youbora.Constants.AdPosition.Preroll;
break;
case 'postroll':
returnValue = youbora.Adapter.AdPosition.POSTROLL;
returnValue = youbora.Constants.AdPosition.Postroll;
break;
case 'midroll':
break;
Expand All @@ -42,9 +42,9 @@ let NativeAdsAdapter = youbora.Adapter.extend({
break;
default:
if (!this.plugin.getAdapter().flags.isJoined) {
returnValue = youbora.Adapter.AdPosition.PREROLL;
} else if (!this.plugin.getAdapter().getIsLive() && this.plugin.getAdapter().getPlayhead() > this.plugin.getAdapter().getDuration() - 1) {
returnValue = youbora.Adapter.AdPosition.POSTROLL;
returnValue = youbora.Constants.AdPosition.Preroll;
} else if (!this.plugin.getIsLive() && this.plugin.getPlayhead() > this.plugin.getDuration() - 1) {
returnValue = youbora.Constants.AdPosition.Postroll;
}
}
return returnValue;
Expand Down Expand Up @@ -119,7 +119,8 @@ let NativeAdsAdapter = youbora.Adapter.extend({
[Event.AD_THIRD_QUARTILE]: this.thirdQuartileListener.bind(this),
[Event.ENTER_FULLSCREEN]: this.enterFullscreenListener.bind(this),
[Event.EXIT_FULLSCREEN]: this.exitFullscreenListener.bind(this),
[Event.AD_MANIFEST_LOADED]: this.manifestLoaded.bind(this)
[Event.AD_MANIFEST_LOADED]: this.manifestLoaded.bind(this),
[Event.AD_BREAK_START]: this.startBreakAdListener.bind(this)
};

for (let key in this.references) {
Expand All @@ -145,10 +146,6 @@ let NativeAdsAdapter = youbora.Adapter.extend({
this.fireBreakStart();
},

endBreakAdListener: function () {
this.fireBreakEnd();
},

loadedAdListener: function (e) {
this.adObject = e.payload.ad;
},
Expand Down Expand Up @@ -184,7 +181,7 @@ let NativeAdsAdapter = youbora.Adapter.extend({

errorAdListener: function (e) {
this.fireError(e.payload.error.code, e.payload.error.message);
if (this.getPosition() === youbora.Adapter.AdPosition.POSTROLL) {
if (this.getPosition() === youbora.Constants.AdPosition.Postroll) {
this.plugin.getAdapter().stopBlockedByAds = false;
this.plugin.fireStop();
}
Expand Down Expand Up @@ -219,7 +216,7 @@ let NativeAdsAdapter = youbora.Adapter.extend({
allAdsCompletedListener: function () {
this.fireStop();
this.plugin.getAdapter().stopBlockedByAds = false;
if (this.getPosition() === youbora.Adapter.AdPosition.POSTROLL) this.plugin.getAdapter().fireStop();
if (this.getPosition() === youbora.Constants.AdPosition.Postroll) this.plugin.getAdapter().fireStop();
this.adPosition = null;
},

Expand All @@ -231,7 +228,7 @@ let NativeAdsAdapter = youbora.Adapter.extend({
resetFlags: function () {
this.currentTime = null;
this.adObject = null;
if (this.getPosition() === youbora.Adapter.AdPosition.POSTROLL) {
if (this.getPosition() === youbora.Constants.AdPosition.Postroll) {
this.adPosition = null;
}
}
Expand Down

0 comments on commit b70634b

Please sign in to comment.