From: Rick Waldron Date: Fri, 18 Feb 2011 20:47:43 +0000 (-0500) Subject: [#349] Round exec times, widen buffer for callback.fired release X-Git-Tag: v0.4~46^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=a249b8cf9d8783fa512581bc69718b93aa6a512a;p=popcorn-js.git [#349] Round exec times, widen buffer for callback.fired release --- diff --git a/popcorn.js b/popcorn.js index c42a5d8..36f7c01 100644 --- a/popcorn.js +++ b/popcorn.js @@ -323,27 +323,26 @@ 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 ); } };