From f0d3b4b9cb3f633fcd9695010957da3022ae6b77 Mon Sep 17 00:00:00 2001 From: David Seifried Date: Fri, 3 Jun 2011 14:20:18 -0400 Subject: [PATCH] [#541] Made the time updating of the baseplayer more accurate using date objects to get the time difference --- players/baseplayer/popcorn.baseplayer.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/players/baseplayer/popcorn.baseplayer.js b/players/baseplayer/popcorn.baseplayer.js index bbccaf3..4765c6a 100644 --- a/players/baseplayer/popcorn.baseplayer.js +++ b/players/baseplayer/popcorn.baseplayer.js @@ -6,6 +6,7 @@ Popcorn.baseplayer.init = function() { this.readyState = 0; this.currentTime = 0; + this.baselineTime = new Date(); this.duration = 0; this.paused = 1; this.ended = 0; @@ -45,16 +46,17 @@ }, timeupdate: function() { - // The player was paused since the last time update - if ( this.paused ) { - return; - } // So we can refer to the instance when setTimeout is run var self = this; - this.currentTime += 0.015; - this.dispatchEvent( "timeupdate" ); + if( !this.paused ) { + this.currentTime += ( new Date() - this.baselineTime ) / 1000; + this.dispatchEvent( "timeupdate" ); + } + + this.baselineTime = new Date(); + setTimeout( function() { self.timeupdate.call( self ); }, 15 ); -- 2.43.0