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:
@ -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');
|
||||||
|
|
||||||
|
// Prevent loading if preload="none" and the current source isn't loaded (#1044)
|
||||||
|
if (preload !== 'none' || readyState) {
|
||||||
// Restore time
|
// Restore time
|
||||||
const onLoadedMetaData = () => {
|
player.once('loadedmetadata', () => {
|
||||||
player.currentTime = currentTime;
|
player.currentTime = currentTime;
|
||||||
};
|
|
||||||
player.once('loadedmetadata', onLoadedMetaData);
|
// Resume playing
|
||||||
|
if (!paused) {
|
||||||
|
player.play();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Load new source
|
// Load new source
|
||||||
player.media.load();
|
player.media.load();
|
||||||
|
|
||||||
// Resume playing
|
|
||||||
if (playing) {
|
|
||||||
player.play();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger change event
|
// Trigger change event
|
||||||
|
Reference in New Issue
Block a user