* volume ( get only, set by calling setVolume() )
*
* load() function
+ * mute() function
*
* Unsupported media attributes:
* buffered
// Better to store them here than on the DOM
this.objVars = {
paused: true,
- duration: -1,
+ duration: Number.NaN,
ended: 0,
- currentTime: -1,
+ currentTime: Number.NaN,
volume: 1,
loop: 0,
initialTime: 0,
duration: function() {
return this.objVars.duration;
},
+ mute: function() {
+ if ( !this.muted() ) {
+ this.objVars.oldVol = this.objVars.volume;
+ this.volume( 0 );
+ } else {
+ this.volume( this.objVars.oldVol );
+ }
+ },
muted: function() {
return this.objVars.volume === 0;
},
}
var popped = Popcorn.vimeo( "player_1", "http://vimeo.com/11127501" ),
- expects = 21,
+ expects = 23,
playCount = 0,
pauseCount = 0,
count = 0,
ok( popped.video.muted(), "Muted set when player volume 0" );
plus();
- popped.volume( 1 );
+ popped.volume( 0.333 );
} else if ( timesCalled === 2 ) {
ok( !popped.video.muted(), "Unmuted when volume not 0" );
plus();
+ popped.mute();
+ } else if ( timesCalled === 3 ) {
+ ok( popped.video.muted(), "Mute mutes when volume is non-zero" );
+ plus();
+
+ popped.mute();
+ } else if ( timesCalled === 4 ) {
+ equals( popped.volume(), 0.333, "Mute unmutes to last volume" );
+ plus();
+
popped.exec( 4, function() {
popped.video.unload();
});
expect( expects );
- stop( 20000 );
+ stop( /* 20000 */ );
ok( "vimeo" in Popcorn, "Vimeo is a method of Popcorn" );
plus();
}
- matches = rIdExp.exec( entity );
-
- if ( matches.length && matches[2] ) {
- elem = document.getElementById(matches[2]);
- }
+ if ( (typeof entity) == "string" ) {
+ matches = rIdExp.exec( entity );
+ if ( matches.length && matches[2] ) {
+ elem = document.getElementById(matches[2]);
+ }
- this.video = elem ? elem : null;
+ this.video = elem ? elem : null;
+ } else if ( entity instanceof Object ) {
+ this.video = entity;
+ }
this.data = {
history: [],
// adding padding to the front and end of the arrays
// this is so we do not fall off either end
- var duration = that.video.duration;
+ var duration = typeof that.video.duration === "function" ? that.video.duration() : that.video.duration;
// Check for no duration info (NaN)
var videoDurationPlus = duration != duration ? Number.MAX_VALUE : duration + 1;
tracksByEnd = tracks.byEnd,
tracksByStart = tracks.byStart;
+
+ if (typeof this.currentTime === "function") {
+ currentTime = this.currentTime();
+ }
+
// Playbar advancing
if ( previousTime < currentTime ) {
}
};
- isReady( this );
+ if ( this.video ) {
+ 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 ) {
- 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 );
- }
+ ret[ name ] = function( arg ) {
+ var isFunc = typeof this.video[name] === "function";
- if ( arg !== false && arg !== null && typeof arg !== "undefined" ) {
+ if ( /load|play|pause|mute/.test( name ) || ( arg !== false && arg !== null && typeof arg !== "undefined" ) ) {
- this.video[ name ] = arg;
+ if ( isFunc ) {
+ this.video[ name ]( arg );
+ } else {
+ 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 ? null : settings.data );
+ settings.ajax.send( settings.data || null );
return Popcorn.xhr.httpData( settings );
}
}, false );
})(window, window.document);
+