[#1320] Cache volume values for synch reasons, and properly update muted... #252

Open
wants to merge 2 commits into
from
View
14 wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js
@@ -73,7 +73,7 @@
controls: true,
loop: false,
poster: EMPTY_STRING,
- volume: -1,
+ volume: 1,
muted: false,
currentTime: 0,
duration: NaN,
@@ -490,27 +490,25 @@
}
function setVolume( aValue ) {
+ impl.volume = aValue;
@jbuck
jbuck Dec 14, 2012

Is it worth having a sanity check in here? IE is this a number between 0 and 1?

Edit - HTML5 video throws an exception (gross!) if you set the volume outside this range.

if( !mediaReady ) {
- impl.volume = aValue;
addMediaReadyCallback( function() {
setVolume( impl.volume );
});
return;
}
- player.setVolume( aValue );
+ player.setVolume( impl.volume * 100 );
self.dispatchEvent( "volumechange" );
}
function getVolume() {
- if( !mediaReady ) {
- return impl.volume > -1 ? impl.volume : 1;
- }
- return player.getVolume();
+ // YouTube has getVolume(), but for sync access we use impl.volume
+ return impl.volume;
}
function setMuted( aValue ) {
+ impl.muted = aValue;
if( !mediaReady ) {
- impl.muted = aValue;
addMediaReadyCallback( function() { setMuted( impl.muted ); } );
return;
}