]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
added fragment update when the player is seeked
authorKarim Hamidou <khamidou@gmail.com>
Wed, 9 Nov 2011 11:42:34 +0000 (12:42 +0100)
committerKarim Hamidou <khamidou@gmail.com>
Wed, 9 Nov 2011 11:42:34 +0000 (12:42 +0100)
plugins/mediafragment/popcorn.mediafragment.js
plugins/mediafragment/popcorn.mediafragment.unit.js

index 0f01e6367fb82681f73f4223e753a2a564cce76a..d2a342507271b251fcae2bc45030e445ecf5a696 100644 (file)
               }
         }
         
-        
-        this.listen( 'loadedmetadata', advanceTime );        
-        this.listen("pause", function(data) {            
+        var updateTime = function() {
             splitArr = window.location.href.split("#")                 
             history.replaceState({}, "", splitArr[0] + "#t=" + this.currentTime().toFixed(2));
-        });
+        };
+        
+        this.listen( 'loadedmetadata', advanceTime );        
+        this.listen("pause", updateTime);
+        this.listen("seeked", updateTime);
         
     },
 
index 0fff2b3cd8fc28db6343d6e2cbd15b002f9aa112..659a273b986b1b64ec2946c8716a34eec1fa6476 100644 (file)
@@ -1,7 +1,7 @@
-test( "Popcorn Footnote Plugin", function() {
+test( "Popcorn Mediafragment Plugin", function() {
 
   var popped = Popcorn( "#video" ),
-      expects = 3,
+      expects = 4,
       count = 0;     
 
   expect( expects );
@@ -34,7 +34,6 @@ test( "Popcorn Footnote Plugin", function() {
 
   popped.exec( 3, function() {
     var currstate = window.location.href.split("#t=");
-    console.log(currstate);
     var time = + currstate[1];
     
     // popcorn's precision is limited to the second.
@@ -42,9 +41,21 @@ test( "Popcorn Footnote Plugin", function() {
     plus();
     popped.play();
   
+    popped.currentTime(5);
+  });
+
+  popped.exec( 6, function() {      
+    var currstate = window.location.href.split("#t=");
+    var time = + currstate[1];
+
+    console.log(time);
+    // popcorn's precision is limited to the second.
+    ok(time >= 5 && time <= 6, "correct time is set after seeking" );
+    plus();   
+  
   });
   
-  popped.exec( 4, function() {
+  popped.exec( 10, function() {
     // clear the address bar
     window.location.href = window.location.href.split("#t=")[0];
   });