]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#541] Made the time updating of the baseplayer more accurate using date objects...
authorDavid Seifried <david.c.seifried@gmail.com>
Fri, 3 Jun 2011 18:20:18 +0000 (14:20 -0400)
committerDavid Seifried <david.c.seifried@gmail.com>
Fri, 3 Jun 2011 18:20:18 +0000 (14:20 -0400)
players/baseplayer/popcorn.baseplayer.js

index bbccaf31e80a27883cb26fb185dc22564ff2025f..4765c6ab5aed52aefc349116e1f461d7558a8afd 100644 (file)
@@ -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;
     },
     
     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 );