]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
removed toggle, reworked start and end. removed old vars
authorChristopher De Cairos <chris.decairos@gmail.com>
Wed, 29 Jun 2011 14:45:28 +0000 (10:45 -0400)
committerChristopher De Cairos <chris.decairos@gmail.com>
Wed, 29 Jun 2011 14:45:28 +0000 (10:45 -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 6116852beea9132761ed98e7885ccf714658b533..54b58ef54af3e01a94f181e83e014a2087e28d91 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 ) {
@@ -54,7 +35,7 @@
 
       if ( !window.Processing ) {
 
-        Popcorn.getScript( "http://processingjs.org/content/download/processing-js-1.2.1/processing-1.2.1.min.js" );
+        Popcorn.getScript( "http://processingjs.org/content/download/processing-js-1.2.1/processing-1.2.1.js" );
       }
 
       options.parentTarget = document.getElementById( options.target );
           });
         };
         
-        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 ) {
-        var that = this,
-        
-        checkCodeReady = function() {
-          if ( options.codeReady ) {
-            toggle.call( that, true, options );
-            return;
-          }
-          
-          setTimeout( checkCodeReady, 5 );
-          
-        };
-        
-        checkCodeReady();
+
+        options.codeReady && !this.media.paused && options.pjsInstance.loop();
+        options.canvas.style.display = "inline";
       },
 
       end: function( event, options ) {
-        var that = this, 
-        
-        checkCodeReady = function() {
-          if ( options.codeReady ) {
-            toggle.call( that, false, options );
-            return;
-          }
-        
-          setTimeout( checkCodeReady, 5 );
-        
-        };
         
-        checkCodeReady();
+        options.pjsInstance && options.pjsInstance.noLoop();
+        options.canvas.style.display = "none";
       },
       
       _teardown: function( options ) {