# HG changeset patch # User hamidouk # Date 1323255064 -3600 # Node ID bae7c50704d7710b512bad3ae1efd7200ab2e219 # Parent 89a79a2c6014e789d84eafbbc2207385458602c0 fixed code() function. The Popcorn workaround now works correctly. diff -r 89a79a2c6014 -r bae7c50704d7 src/js/pop.js --- a/src/js/pop.js Fri Dec 02 15:42:06 2011 +0100 +++ b/src/js/pop.js Wed Dec 07 11:51:04 2011 +0100 @@ -30,27 +30,7 @@ options.events = { onReady: Popcorn.__initApi, onTime: Popcorn.__timeHandler, - onSeek: function(event) { - var i = 0; - console.log("old: %d, new: %d", event.position, event.offset); - for(i = 0; i < Popcorn.__codes.length; i++) { - var c = Popcorn.__codes[i]; - - if (event.position >= c.start && event.position < c.end) { - c.onEnd(); - } - - if (typeof(event.offset) === "undefined") - event.offset = 0; - if (event.offset >= c.start && event.offset < c.end) { - c.onStart(); - } - - } - - Popcorn.trigger("timeupdate"); - } - } + onSeek: Popcorn.__seekHandler } jwplayer(Popcorn._container).setup(options); Popcorn.media.duration = options.duration; @@ -129,10 +109,49 @@ (onTime event) */ -Popcorn.__timeHandler = function() { +Popcorn.__timeHandler = function(event) { + var pos = event.position; + + var i = 0; + for(i = 0; i < Popcorn.__codes.length; i++) { + var c = Popcorn.__codes[i]; + + if (pos >= c.start && pos < c.end && + pos - 0.1 <= c.start) { + c.onStart(); + } + + if (pos >= c.start && pos >= c.end && + pos - 0.1 <= c.end) { + c.onEnd(); + } + + } + Popcorn.trigger("timeupdate"); }; +Popcorn.__seekHandler = function(event) { + var i = 0; + for(i = 0; i < Popcorn.__codes.length; i++) { + var c = Popcorn.__codes[i]; + + if (event.position >= c.start && event.position < c.end) { + c.onEnd(); + } + + if (typeof(event.offset) === "undefined") + event.offset = 0; + if (event.offset >= c.start && event.offset < c.end) { + c.onStart(); + } + + } + + Popcorn.trigger("timeupdate"); +} + + Popcorn.roundTime = function() { var currentTime = Popcorn.currentTime(); return Math.round(currentTime);