Skip to content

Instantly share code, notes, and snippets.

@oberhamsi
Last active April 28, 2020 06:56
Show Gist options
  • Save oberhamsi/93b0c9ca1e5ea3fa5824981b3f25f046 to your computer and use it in GitHub Desktop.
Save oberhamsi/93b0c9ca1e5ea3fa5824981b3f25f046 to your computer and use it in GitHub Desktop.
this.isAdRunning = false;
this.hasContentEnded = false;
this.on('adbreakstarted', () => {
this.isAdRunning = true;
});
this.on('timechanged', () => {
const diff = this.getDuration() - this.getCurrentTime();
if (this.hasContentEnded == false && this.isAd() == false && diff < 1) {
this.hasContentEnded = true;
this.trigger('player:contentended');
} else if (this.isAdRunning == true && diff < 1 && this.isAd()) {
this.isAdRunning = false;
this.trigger("player:adended");
}
});
this.on('adbreakfinished', () => {
if (this.isAd() == false && this.hasContentEnded == false) {
this.trigger('player:contentstarted');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment