]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
removed toggle, reworked start and end. removed old vars t637b
authorChristopher De Cairos <chris.decairos@gmail.com>
Wed, 29 Jun 2011 15:12:18 +0000 (11:12 -0400)
committerChristopher De Cairos <chris.decairos@gmail.com>
Wed, 29 Jun 2011 15:12:18 +0000 (11:12 -0400)
plugins/processing/popcorn.processing.html
plugins/processing/popcorn.processing.js

index 94bb360def78cd33a20bb0b0a3cf59c1a817ac11..33f7a2195e63dcd2e007738f9e42089995305455 100644 (file)
@@ -11,7 +11,7 @@
       .volume( 0 )
       .play()
       .processing({
-        start: 2,
+        start: 0,
         end: 10,
         target: "processing-div",
         sketch: "test.pjs",
@@ -47,7 +47,7 @@
   
   <div>
     <video id='video'
-      controls preload='none'
+      controls preload="auto"
       width= '250px'
       poster="../../test/poster.png">
 
index 560e4ff1ea8af97c4e315255a062d71e86e9aa1b..60e2327a899654e73de1528401368f18d86be5e4 100644 (file)
 
 (function ( Popcorn ) {
 
-  var toggle = function( on, options ) {
-        var instance = options.pjsInstance,
-            canvas = options.canvas;
-            
-        if ( canvas && options.isReady ) {
-          if ( on ) {
-            canvas.style.display = "inline";
-            !this.media.paused && instance.loop();
-          } else {
-            canvas.style.display = "none";
-            instance.noLoop();
-          }
-        } else {
-          setTimeout (function() {
-            toggle.call( this, on, options );
-          }, 10 );
-        }
-      };
-
   Popcorn.plugin( "processing" , function ( options ) {
 
     var init = function( context ) {
           });
         };
         
-        if ( options.codeReady && window.Processing ) {
+        if ( window.Processing ) {
+
           options.pjsInstance = new Processing( options.canvas, options.processingCode );
           options.pjsInstance.noLoop();
+          options.seeking = false;
           context.listen( "seeking", function() {
-            if ( options.canvas.style.display === "inline" && options.noPause ) {
-              options.pjsInstance.loop();
-            }
+             options._running && options.canvas.style.display === "inline" && options.noPause && options.pjsInstance.loop();
           });
+
+          options._running && !context.media.paused && options.pjsInstance.loop();
           
           options.noPause = options.noPause || false;
-          !options.noPause && addListeners();          
-          options.isReady = true;
+          !options.noPause && addListeners(); 
+          options.codeReady = true;         
         } else {
-          setTimeout ( initProcessing, 10 );
+          setTimeout ( function() {
+            initProcessing.call( this );
+            }, 10 );
         }
       };
       
         url: options.sketch,
         dataType: "text",
         success: function( responseCode ) {
-          options.codeReady = true;
           options.processingCode = responseCode;
-          initProcessing();
+          initProcessing.call( context );
         }
       });
     };
       },
 
       start: function( event, options ) {
-        toggle.call( this, true, options );
+
+        options.codeReady && !this.media.paused && options.pjsInstance.loop();
+        options.canvas.style.display = "inline";
       },
 
       end: function( event, options ) {
-        toggle.call( this, false, options );
+        
+        options.pjsInstance && options.pjsInstance.noLoop();
+        options.canvas.style.display = "none";
       },
       
       _teardown: function( options ) {