YouTube volume fix
This commit is contained in:
@ -126,22 +126,28 @@ const vimeo = {
|
||||
},
|
||||
});
|
||||
|
||||
// Muted
|
||||
Object.defineProperty(player.media, 'muted', {
|
||||
get() {
|
||||
return volume === 0;
|
||||
},
|
||||
set(input) {
|
||||
const toggle = utils.is.boolean(input) ? input : false;
|
||||
player.volume = toggle ? 0 : player.config.volume;
|
||||
},
|
||||
});
|
||||
|
||||
// Source
|
||||
let currentSrc;
|
||||
|
||||
player.embed.getVideoUrl().then(value => {
|
||||
currentSrc = value;
|
||||
});
|
||||
|
||||
Object.defineProperty(player.media, 'currentSrc', {
|
||||
get() {
|
||||
return currentSrc;
|
||||
},
|
||||
});
|
||||
|
||||
// Rebuild UI
|
||||
window.setTimeout(() => ui.build.call(player), 0);
|
||||
|
||||
// Get title
|
||||
player.embed.getVideoTitle().then(title => {
|
||||
player.config.title = title;
|
||||
@ -222,6 +228,9 @@ const vimeo = {
|
||||
this.media.paused = true;
|
||||
utils.dispatchEvent.call(this, this.media, 'ended');
|
||||
});
|
||||
|
||||
// Rebuild UI
|
||||
window.setTimeout(() => ui.build.call(player), 0);
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -145,12 +145,26 @@ const youtube = {
|
||||
});
|
||||
|
||||
// Volume
|
||||
let volume = instance.getVolume() / 100;
|
||||
Object.defineProperty(player.media, 'volume', {
|
||||
get() {
|
||||
return instance.getVolume() / 100;
|
||||
return volume;
|
||||
},
|
||||
set(input) {
|
||||
instance.setVolume(input * 100);
|
||||
volume = input;
|
||||
instance.setVolume(volume * 100);
|
||||
utils.dispatchEvent.call(player, player.media, 'volumechange');
|
||||
},
|
||||
});
|
||||
|
||||
// Muted
|
||||
Object.defineProperty(player.media, 'muted', {
|
||||
get() {
|
||||
return instance.isMuted();
|
||||
},
|
||||
set(input) {
|
||||
const toggle = utils.is.boolean(input) ? input : false;
|
||||
instance[toggle ? 'mute' : 'unMute']();
|
||||
utils.dispatchEvent.call(player, player.media, 'volumechange');
|
||||
},
|
||||
});
|
||||
@ -175,9 +189,6 @@ const youtube = {
|
||||
player.media.setAttribute('tabindex', -1);
|
||||
}
|
||||
|
||||
// Rebuild UI
|
||||
window.setTimeout(() => ui.build.call(player), 0);
|
||||
|
||||
utils.dispatchEvent.call(player, player.media, 'timeupdate');
|
||||
utils.dispatchEvent.call(player, player.media, 'durationchange');
|
||||
|
||||
@ -205,6 +216,9 @@ const youtube = {
|
||||
utils.dispatchEvent.call(player, player.media, 'canplaythrough');
|
||||
}
|
||||
}, 200);
|
||||
|
||||
// Rebuild UI
|
||||
window.setTimeout(() => ui.build.call(player), 50);
|
||||
},
|
||||
onStateChange(event) {
|
||||
// Get the instance
|
||||
|
Reference in New Issue
Block a user