fixed popcorn replacement bug where onEnd would be called after onStart. popcorn-port
authorhamidouk
Mon, 19 Dec 2011 08:59:31 +0100
branchpopcorn-port
changeset 475 5c254621cd9c
parent 474 c1998d5d552e
child 476 3957157b7f96
fixed popcorn replacement bug where onEnd would be called after onStart.
src/js/pop.js
--- a/src/js/pop.js	Fri Dec 16 18:16:23 2011 +0100
+++ b/src/js/pop.js	Mon Dec 19 08:59:31 2011 +0100
@@ -144,12 +144,13 @@
      var c = IriSP.PopcornReplacement.__codes[i];
      
      if (pos >= c.start && pos < c.end && 
-         pos - 0.1 <= c.start) {
+         pos - 0.1 <= c.start) {       
         c.onStart();
      }
  
-     if (pos >= c.start && pos >= c.end && 
+     if (pos > c.start && pos > c.end && 
          pos - 0.1 <= c.end) {
+         console.log("eonedn");
         c.onEnd();
      }
    
@@ -158,18 +159,26 @@
   IriSP.PopcornReplacement.trigger("timeupdate");
 };
 
-IriSP.PopcornReplacement.__seekHandler = function(event) { 
+IriSP.PopcornReplacement.__seekHandler = function(event) {
+  console.log(IriSP.PopcornReplacement.__codes.length);
+  
   var i = 0;
+  
   for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) {
      var c = IriSP.PopcornReplacement.__codes[i];
     
-     if (event.position >= c.start && event.position < c.end) {
+     if (event.position >= c.start && event.position < c.end) {        
         c.onEnd();
-     }
-    
+     }         
+   }
+
+   for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) {
+     var c = IriSP.PopcornReplacement.__codes[i];
+
      if (typeof(event.offset) === "undefined")
        event.offset = 0;
-     if (event.offset >= c.start && event.offset < c.end) {
+           
+     if (event.offset >= c.start && event.offset < c.end) { 
        c.onStart();
      }