diff --git a/videojs.vast.js b/videojs.vast.js index aeccceb..429847e 100644 --- a/videojs.vast.js +++ b/videojs.vast.js @@ -135,13 +135,11 @@ } player.vastTracker.setProgress(player.currentTime()); }, - playFn = function() { - if (player.ads.state === 'ad-playback') { - player.vastTracker.setPaused(false); - } - }, pauseFn = function() { player.vastTracker.setPaused(true); + player.one('play', function(){ + player.vastTracker.setPaused(false); + }); }, errorFn = function() { // Inform ad server we couldn't play the media file for this ad @@ -152,14 +150,12 @@ player.on('canplay', canplayFn); player.on('timeupdate', timeupdateFn); - player.on('play', playFn); player.on('pause', pauseFn); player.on('error', errorFn); - player.one('ended', function() { + player.one('vast-preroll-removed', function() { player.off('canplay', canplayFn); player.off('timeupdate', timeupdateFn); - player.off('play', playFn); player.off('pause', pauseFn); player.off('error', errorFn); if (!errorOccurred) {