Skip to content

Commit

Permalink
fix: AD_STARTED fires before ad started with AWS Media Tailor (#5855)
Browse files Browse the repository at this point in the history
Fixes #5854
  • Loading branch information
avelad authored Nov 3, 2023
1 parent 508e5cf commit b39f334
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/ads/media_tailor_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,13 @@ shaka.ads.MediaTailorAdManager = class {
*/
setupCurrentAdListeners_() {
const MediaTailorAdManager = shaka.ads.MediaTailorAdManager;
this.sendTrackingEvent_(MediaTailorAdManager.IMPRESSION_);
this.sendTrackingEvent_(MediaTailorAdManager.START_);
let needFirstEvents = false;
if (!this.video_.paused) {
this.sendTrackingEvent_(MediaTailorAdManager.IMPRESSION_);
this.sendTrackingEvent_(MediaTailorAdManager.START_);
} else {
needFirstEvents = true;
}
this.adListeners_.push({
target: this.video_,
type: 'volumechange',
Expand All @@ -636,7 +641,13 @@ shaka.ads.MediaTailorAdManager = class {
target: this.video_,
type: 'play',
listener: () => {
this.sendTrackingEvent_(MediaTailorAdManager.RESUME_);
if (needFirstEvents) {
this.sendTrackingEvent_(MediaTailorAdManager.IMPRESSION_);
this.sendTrackingEvent_(MediaTailorAdManager.START_);
needFirstEvents = false;
} else {
this.sendTrackingEvent_(MediaTailorAdManager.RESUME_);
}
},
});
this.adListeners_.push({
Expand Down

0 comments on commit b39f334

Please sign in to comment.