]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#280] Quick fix to allow pause(), play(), load(), mute() to work on native
authorstevenaw <sweerdenburg@gmail.com>
Tue, 8 Mar 2011 04:01:35 +0000 (23:01 -0500)
committerstevenaw <sweerdenburg@gmail.com>
Tue, 8 Mar 2011 04:01:35 +0000 (23:01 -0500)
popcorn.js

index 4bb3a53ba906ec0834c4c053e32752d3d892c1cc..fc98f3e51005425904a4c1054a7986463091ed56 100644 (file)
       }
 
 
-      if ( (typeof entity) == "string" ) {
-        matches = rIdExp.exec( entity );
+      matches = rIdExp.exec( entity );
 
-        if ( matches.length && matches[2]  ) {
-          elem = document.getElementById(matches[2]);
-        }
-
-        this.video = elem ? elem : null;
-      } else if ( entity instanceof Object ) {
-        this.video = entity;
+      if ( matches.length && matches[2]  ) {
+        elem = document.getElementById(matches[2]);
       }
 
+
+      this.video = elem ? elem : null;
+
       this.data = {
         history: [],
         events: {},
                 tracksByEnd    = tracks.byEnd,
                 tracksByStart  = tracks.byStart;
 
-
-            if (typeof currentTime === "function") {
-              currentTime = this.currentTime();
-            }
-
             // Playbar advancing
             if ( previousTime < currentTime ) {
 
         }
       };
 
-      if ( this.video ) {
-        isReady( this );
-      }
+      isReady( this );
 
       return this;
     }
 
       //  Build methods, store in object that is returned and passed to extend
       Popcorn.forEach( methods.split(/\s+/g), function( name ) {
-
+          
         ret[ name ] = function( arg ) {
 
-          var isFunc = typeof this.video[name] === "function";
+          if ( typeof this.video[name] === "function" ) {
+            // Looad, play, pause, mute do not reeturn a value when nothing is passed to them
+            if ( /load|play|pause|mute/.test( name ) || arg !== false && arg !== null && typeof arg !== "undefined" ) {
+            
+              this.video[ name ]();
+              return this;
+              
+            }
+            
+            return this.video[ name ]( arg );
+          }
+
 
           if ( arg !== false && arg !== null && typeof arg !== "undefined" ) {
 
-            if ( isFunc ) {
-              this.video[ name ](arg);
-            } else {
-              this.video[ name ] = arg;
-            }
+            this.video[ name ] = arg;
 
             return this;
           }
 
-          if ( isFunc ) {
-            return this.video[ name ]();
-          }
-
           return this.video[ name ];
         };
       });
 
 
       settings.ajax.open( settings.type, settings.url, settings.async );
-      settings.ajax.send( settings.data || null );
+      settings.ajax.send( settings.data = null ? null : settings.data );
 
       return Popcorn.xhr.httpData( settings );
     }
   }, false );
 
 })(window, window.document);
-