]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
fixed Popcorn.removeInstance and added popcornInstance.id
authorMatt <carnage6000@gmail.com>
Mon, 7 Mar 2011 20:38:06 +0000 (15:38 -0500)
committerMatt <carnage6000@gmail.com>
Mon, 7 Mar 2011 20:38:06 +0000 (15:38 -0500)
popcorn.js
test/instanceTester.html [deleted file]

index e2df62f19dacf6c49355c23fbd641a4b6b2992b1..e46d7b4c973d0f38f8fd0c4d43b865840df7c2d3 100644 (file)
   };
   
   Popcorn.instances = [];
+  
   Popcorn.instanceIds = {};
   
-  Popcorn.removeInstance = function( id ) {
+  Popcorn.id = null;
+  
+  Popcorn.removeInstance = function( popcornInstance ) {
     //  If called prior to any instances being created
     //  Return early to avoid splicing on nothing
     if ( !Popcorn.instances.length ) {
@@ -34,9 +37,9 @@
       
     }
   
-    Popcorn.instances.splice( Popcorn.instanceIds[ id ], 1 );
+    Popcorn.instances.splice( Popcorn.instanceIds[ popcornInstance.id ], 1 );
 
-    delete Popcorn.instanceIds[ id ];
+    delete Popcorn.instanceIds[ popcornInstance.id ];
     
   };
 
   
     if ( !popcornInstance.video.id ) { 
     
-      popcornInstance.video.id = "__popcorn" + Popcorn.instances.length;
+      popcornInstance.id = "__popcorn" + Popcorn.instances.length;
+    
+    }
+    
+    else {
+    
+      popcornInstance.id = popcornInstance.video.id;
     
     }
     
-    Popcorn.instanceIds[ popcornInstance.video.id ] = Popcorn.instances.length;
+    Popcorn.instanceIds[ popcornInstance.id ] = Popcorn.instances.length;
     
     Popcorn.instances.push( popcornInstance );
     
diff --git a/test/instanceTester.html b/test/instanceTester.html
deleted file mode 100644 (file)
index 39ff91b..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Popcorn API</title>
-  <link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
-  <script src="../popcorn.js"></script>
-  <script>
-  
-  Popcorn(function (e) {
-    var p = Popcorn("#video");
-  });
-
-  Popcorn(function () {
-    var p = Popcorn("#video2");
-    p.play();
-    Popcorn.getInstanceById("video").play();
-  });  
-  </script>
-  
-</head>
-<body>
-  <video id='video'style="display:" 
-    controls 
-    poster="http://media.w3.org/2010/05/sintel/poster.png"> 
-
-    <source id='mp4'
-      src="http://media.w3.org/2010/05/sintel/trailer.mp4"
-      type='video/mp4; codecs="avc1, mp4a"'> 
-
-    <source id='ogv'
-      src="http://media.w3.org/2010/05/sintel/trailer.ogv"
-      type='video/ogg; codecs="theora, vorbis"'> 
-
-    <p>Your user agent does not support the HTML5 Video element.</p> 
-
-  </video>   
-  <video id='video2'style="display:" 
-    controls 
-    poster="http://media.w3.org/2010/05/sintel/poster.png"> 
-
-    <source id='mp4'
-      src="http://media.w3.org/2010/05/sintel/trailer.mp4"
-      type='video/mp4; codecs="avc1, mp4a"'> 
-
-    <source id='ogv'
-      src="http://media.w3.org/2010/05/sintel/trailer.ogv"
-      type='video/ogg; codecs="theora, vorbis"'> 
-
-    <p>Your user agent does not support the HTML5 Video element.</p> 
-
-  </video>   
-</body>
-</html>