diff options
author | Albin Larsson <mail@albinlarsson.com> | 2018-06-11 06:34:02 +0200 |
---|---|---|
committer | Albin Larsson <mail@albinlarsson.com> | 2018-06-12 02:31:18 +0200 |
commit | ed606c28abec076ba164ec600a743a2bdd3307f2 (patch) | |
tree | 9bdcb6d4c3c259fe5013411fe1962e7db86e339e /src | |
parent | f15e07f7f54975caf41c975d06138d3846d22c03 (diff) | |
download | plyr-ed606c28abec076ba164ec600a743a2bdd3307f2.tar.lz plyr-ed606c28abec076ba164ec600a743a2bdd3307f2.tar.xz plyr-ed606c28abec076ba164ec600a743a2bdd3307f2.zip |
Filter out unsupported mimetypes in getSources() instead of the quality setter
Diffstat (limited to 'src')
-rw-r--r-- | src/js/html5.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/js/html5.js b/src/js/html5.js index a7ff0bd9..8f23b3c1 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -11,7 +11,10 @@ const html5 = { 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 @@ -46,14 +49,11 @@ const html5 = { // Get sources const sources = html5.getSources.call(player); - // Get matches for requested size - const matches = sources.filter(source => Number(source.getAttribute('size')) === input); - - // Get supported sources - const supported = matches.filter(source => support.mime.call(player, source.getAttribute('type'))); + // Get first match for requested size + const source = sources.find(source => Number(source.getAttribute('size')) === input); - // No supported sources - if (utils.is.empty(supported)) { + // No matching source found + if (!source) { return; } @@ -66,7 +66,7 @@ const html5 = { const { currentTime, playing } = player; // Set new source - player.media.src = supported[0].getAttribute('src'); + player.media.src = source.getAttribute('src'); // Restore time const onLoadedMetaData = () => { |