Filter out unsupported mimetypes in getSources() instead of the quality setter

This commit is contained in:
Albin Larsson 2018-06-11 06:34:02 +02:00
parent f15e07f7f5
commit ed606c28ab

View File

@ -11,7 +11,10 @@ const html5 = {
return []; return [];
} }
return Array.from(this.media.querySelectorAll('source')); const sources = Array.from(this.media.querySelectorAll('source'));
// Filter out unsupported sources
return sources.filter(source => support.mime.call(this, source.getAttribute('type')));
}, },
// Get quality levels // Get quality levels
@ -46,14 +49,11 @@ const html5 = {
// Get sources // Get sources
const sources = html5.getSources.call(player); const sources = html5.getSources.call(player);
// Get matches for requested size // Get first match for requested size
const matches = sources.filter(source => Number(source.getAttribute('size')) === input); const source = sources.find(source => Number(source.getAttribute('size')) === input);
// Get supported sources // No matching source found
const supported = matches.filter(source => support.mime.call(player, source.getAttribute('type'))); if (!source) {
// No supported sources
if (utils.is.empty(supported)) {
return; return;
} }
@ -66,7 +66,7 @@ const html5 = {
const { currentTime, playing } = player; const { currentTime, playing } = player;
// Set new source // Set new source
player.media.src = supported[0].getAttribute('src'); player.media.src = source.getAttribute('src');
// Restore time // Restore time
const onLoadedMetaData = () => { const onLoadedMetaData = () => {