}
- 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);
-