]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#349] Round exec times, widen buffer for callback.fired release
authorRick Waldron <waldron.rick@gmail.com>
Fri, 18 Feb 2011 20:47:43 +0000 (15:47 -0500)
committerRick Waldron <waldron.rick@gmail.com>
Fri, 18 Feb 2011 20:47:43 +0000 (15:47 -0500)
popcorn.js

index c42a5d8c282a9fd94f650af722163236cfcab654..36f7c01ea11649d8e0984495afeadfb7744a53b5 100644 (file)
       return -~this.video.currentTime;
     },
     
-    
     exec: function ( time, fn ) {
       
       !fn && ( fn = Popcorn.nop );
       
-      
       var self = this, 
           guid = Popcorn.guid( "execCallback" ), 
           callback = function execCallback( event ) {
+
+            if ( Math.round( this.currentTime() ) === time && !callback.fired ) {
             
-            if ( this.currentTime() >= time && !callback.fired ) {
-              
               callback.fired = true;
               
               fn.call(self, event);
               
+              //  Enforce a once per second execution
               setTimeout(function() {
                 
                 callback.fired = false;
                 
-              }, 500 );
+              }, 1000 );
             }
           };