Fixes #1044: Don't load the new source if preload is disabled and the current source hasn't been loaded

This commit is contained in:
Albin Larsson
2018-06-19 03:34:07 +02:00
parent 94055f0772
commit d72e502107

View File

@ -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