fixed seeking bug. popcorn-port
authorhamidouk
Tue, 31 Jan 2012 11:58:46 +0100
branchpopcorn-port
changeset 749 e9ee52225395
parent 748 ec1f7aa873f4
child 750 a1a3d09de1f4
fixed seeking bug.
src/js/modules/mediafragment.js
src/js/pop.js
--- a/src/js/modules/mediafragment.js	Tue Jan 31 11:58:26 2012 +0100
+++ b/src/js/modules/mediafragment.js	Tue Jan 31 11:58:46 2012 +0100
@@ -40,7 +40,10 @@
               }
 };
 
-IriSP.MediaFragment.prototype.updateTime = function() {
+/** handler for the seeked signal. It may have or may have not an argument.
+    @param time if not undefined, the time we're seeking to 
+*/
+IriSP.MediaFragment.prototype.updateTime = function(time) {
   if (this.mutex === true) {
     return;
   }
@@ -50,8 +53,15 @@
     return false;
   }
   
+  
+  if (IriSP.null_or_undefined(time)) {
+    var ntime = this._Popcorn.currentTime().toFixed(2)
+  } else {
+    var ntime = time.toFixed(2);
+  }
+  
   splitArr = window.location.href.split( "#" )
-  history.replaceState( {}, "", splitArr[0] + "#t=" + this._Popcorn.currentTime().toFixed( 2 ) );
+  history.replaceState( {}, "", splitArr[0] + "#t=" + ntime );
 };
 
 
@@ -67,6 +77,7 @@
   splitArr = window.location.href.split( "#" )
   history.replaceState( {}, "", splitArr[0] + "#id=" + annotationId);
  
+  // reset the mutex afterwards to prevent the module from reacting to his own changes.
   window.setTimeout(function() { _this.mutex = false }, 50);
 };
 
--- a/src/js/pop.js	Tue Jan 31 11:58:26 2012 +0100
+++ b/src/js/pop.js	Tue Jan 31 11:58:46 2012 +0100
@@ -198,7 +198,7 @@
      
    }
   
-  this.trigger("seeked");  
+  this.trigger("seeked", event.offset);  
 };
 
 IriSP.PopcornReplacement.player.prototype.__playHandler = function(event) {