]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Added in alias for in/out and added tests to support it
authorDavid Seifried <david.c.seifried@gmail.com>
Wed, 14 Sep 2011 15:23:41 +0000 (11:23 -0400)
committerDavid Seifried <david.c.seifried@gmail.com>
Wed, 14 Sep 2011 15:23:41 +0000 (11:23 -0400)
popcorn.js
test/popcorn.unit.js

index a17798293a6ce3fe90290bf1a5653e8223cdcf24..8c04fb288c4cff2adedcd1af16808f22a7f28d0b 100644 (file)
 
       //  Ensure a manifest object, an empty object is a sufficient fallback
       options._natives.manifest = manifest;
+      
+      
+      if ( options[ "in" ] ) {
+          options.start = options[ "in" ];
+      }
+
+      if ( options[ "out" ] ) {
+          options.end = options[ "out" ];
+      }
 
       //  Checks for expected properties
       if ( !( "start" in options ) ) {
index 89855e7d552a777251893403ca4a636faa6ce166..f3fd67a2154be45d08445e54b0b490f710db593c 100644 (file)
@@ -2578,6 +2578,66 @@ test("Defaulting Empty End Values", function() {
   });
 });
 
+test( "In/Out aliases", function() {
+  var popcorn = Popcorn( "#video" ),
+      expects = 3,
+      count = 0,
+      aliasDiv = document.createElement( "div" );
+      
+  document.body.appendChild( aliasDiv );
+
+  expect( expects );
+  stop( 5000 );
+
+  function plus() {
+    if ( ++count === expects ) {
+      Popcorn.removePlugin( "aliasTester" );
+      document.body.removeChild( aliasDiv );
+      start();
+    }
+  }
+
+  aliasDiv.id = "aliasDiv";
+
+  Popcorn.plugin( "aliasTester", function() {
+
+    return {
+      start: function() {
+        var div = document.getElementById( "aliasDiv" );
+        div.style.display = "inline";
+        div.innerHTML = "Showing";       
+      },
+      end: function() {
+        var div = document.getElementById( "aliasDiv" );
+        div.innerHTML = "";
+        div.style.display = "none";   
+      }
+    };
+  });
+
+  popcorn.aliasTester({
+    in: 1,
+    out: 3
+  });
+
+  popcorn.currentTime( 0 ).pause();
+
+  equals( aliasDiv.innerHTML, "", "Container is initially empty" );
+  plus();
+
+  popcorn.exec( 2, function() {
+    equals( aliasDiv.innerHTML, "Showing", "Container is displaying 'Showing', in alias is working" );
+    plus();
+  });
+
+  popcorn.exec( 4, function() {
+    equals( aliasDiv.innerHTML, "", "Container is displaying nothing again, out alias is working" );
+    plus();
+  });
+
+  popcorn.play();
+});
+
 module("Popcorn TrackEvents");
 test("Functions", function() {