Merge branch 'develop'

This commit is contained in:
Sam Potts 2018-06-19 16:40:54 +10:00
commit de7832eb8b
2 changed files with 16 additions and 14 deletions

View File

@ -39,7 +39,7 @@ const html5 = {
get() { get() {
// Get sources // Get sources
const sources = html5.getSources.call(player); const sources = html5.getSources.call(player);
const [source] = sources.filter(source => source.getAttribute('src') === player.source); const source = sources.find(source => source.getAttribute('src') === player.source);
// Return size, if match is found // Return size, if match is found
return source && Number(source.getAttribute('size')); return source && Number(source.getAttribute('size'));
@ -57,23 +57,25 @@ const html5 = {
} }
// Get current state // Get current state
const { currentTime, playing } = player; const { currentTime, paused, preload, readyState } = player.media;
// Set new source // Set new source
player.media.src = source.getAttribute('src'); player.media.src = source.getAttribute('src');
// Restore time // Prevent loading if preload="none" and the current source isn't loaded (#1044)
const onLoadedMetaData = () => { if (preload !== 'none' || readyState) {
player.currentTime = currentTime; // Restore time
}; player.once('loadedmetadata', () => {
player.once('loadedmetadata', onLoadedMetaData); player.currentTime = currentTime;
// Load new source // Resume playing
player.media.load(); if (!paused) {
player.play();
}
});
// Resume playing // Load new source
if (playing) { player.media.load();
player.play();
} }
// Trigger change event // Trigger change event

View File

@ -270,8 +270,8 @@ const youtube = {
return Number(instance.getCurrentTime()); return Number(instance.getCurrentTime());
}, },
set(time) { set(time) {
// If paused, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet). // If paused and never played, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet).
if (player.paused) { if (player.paused && !player.embed.hasPlayed) {
player.embed.mute(); player.embed.mute();
} }