From: David Seifried Date: Fri, 3 Jun 2011 18:20:18 +0000 (-0400) Subject: [#541] Made the time updating of the baseplayer more accurate using date objects... X-Git-Tag: v0.7^2~14^2~2^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=f0d3b4b9cb3f633fcd9695010957da3022ae6b77;p=popcorn-js.git [#541] Made the time updating of the baseplayer more accurate using date objects to get the time difference --- 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 );