Skip to content

Commit

Permalink
fix: fixes bug with multiple contentEndedListeners being registered
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiro705 committed Oct 3, 2019
1 parent 317cdaa commit 2208d86
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/player-wrapper.js
Expand Up @@ -599,6 +599,11 @@ PlayerWrapper.prototype.addContentEndedListener = function(listener) {
* Reset the player.
*/
PlayerWrapper.prototype.reset = function() {
// Attempts to remove the contentEndedListener before adding it.
// This is to prevent an error where an erroring video caused multiple
// contentEndedListeners to be added.
this.vjsPlayer.off('contentended', this.boundContentEndedListener);

this.vjsPlayer.on('contentended', this.boundContentEndedListener);
this.vjsControls.show();
if (this.vjsPlayer.ads.inAdBreak()) {
Expand Down

0 comments on commit 2208d86

Please sign in to comment.