Skip to content

Commit

Permalink
Fixes after calling player.dispose().
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 595710592
  • Loading branch information
google-ima-devrel-bot authored and IMA Developer Relations committed Jan 4, 2024
1 parent ed05430 commit 75ecf39
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/client-side/player-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ const PlayerWrapper = function(player, adsPluginSettings, controller) {
* Set up the intervals we use on the player.
*/
PlayerWrapper.prototype.setUpPlayerIntervals = function() {
/**
* Clear old interval handers in case the method was called more than once
*/
if (this.updateTimeIntervalHandle) {
clearInterval(this.updateTimeIntervalHandle);
}
if (this.seekCheckIntervalHandle) {
clearInterval(this.seekCheckIntervalHandle);
}
if (this.resizeCheckIntervalHandle) {
clearInterval(this.resizeCheckIntervalHandle);
}

this.updateTimeIntervalHandle =
setInterval(this.updateCurrentTime.bind(this), this.updateTimeInterval);
this.seekCheckIntervalHandle =
Expand Down Expand Up @@ -225,9 +238,6 @@ PlayerWrapper.prototype.localContentEndedListener = function() {
}
}

clearInterval(this.updateTimeIntervalHandle);
clearInterval(this.seekCheckIntervalHandle);
clearInterval(this.resizeCheckIntervalHandle);
if (this.vjsPlayer.el()) {
this.vjsPlayer.one('play', this.setUpPlayerIntervals.bind(this));
}
Expand Down

0 comments on commit 75ecf39

Please sign in to comment.