From: stevenaw Date: Tue, 8 Mar 2011 04:01:35 +0000 (-0500) Subject: [#280] Quick fix to allow pause(), play(), load(), mute() to work on native X-Git-Tag: v0.4~6^2~12 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=dbe3fdf68e49ab0e51b60888ee866e206b4285b5;p=popcorn-js.git [#280] Quick fix to allow pause(), play(), load(), mute() to work on native --- diff --git a/popcorn.js b/popcorn.js index 4bb3a53..fc98f3e 100644 --- a/popcorn.js +++ b/popcorn.js @@ -78,18 +78,15 @@ } - 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: {}, @@ -131,11 +128,6 @@ tracksByEnd = tracks.byEnd, tracksByStart = tracks.byStart; - - if (typeof currentTime === "function") { - currentTime = this.currentTime(); - } - // Playbar advancing if ( previousTime < currentTime ) { @@ -222,9 +214,7 @@ } }; - if ( this.video ) { - isReady( this ); - } + isReady( this ); return this; } @@ -303,26 +293,29 @@ // 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 ]; }; }); @@ -915,7 +908,7 @@ 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 ); } @@ -1115,4 +1108,3 @@ }, false ); })(window, window.document); -