diff --git a/src/components/qualityOptions.js b/src/components/qualityOptions.js index 5e7230eefd..bdf20e279a 100644 --- a/src/components/qualityOptions.js +++ b/src/components/qualityOptions.js @@ -52,19 +52,16 @@ export function getVideoQualityOptions(options) { qualityOptions.push({ name: '360p - 420 kbps', maxHeight: 360, bitrate: 420000 }); if (maxStreamingBitrate) { - let selectedIndex = -1; + let selectedIndex = qualityOptions.length - 1; for (let i = 0, length = qualityOptions.length; i < length; i++) { const option = qualityOptions[i]; - if (selectedIndex === -1 && option.bitrate <= maxStreamingBitrate) { + if (option.bitrate > 0 && option.bitrate <= maxStreamingBitrate) { selectedIndex = i; + break; } } - if (selectedIndex === -1) { - selectedIndex = qualityOptions.length - 1; - } - const currentQualityOption = qualityOptions[selectedIndex]; if (!options.isAutomaticBitrateEnabled) { @@ -103,19 +100,16 @@ export function getAudioQualityOptions(options) { qualityOptions.push({ name: '64 kbps', bitrate: 64000 }); if (maxStreamingBitrate) { - let selectedIndex = -1; + let selectedIndex = qualityOptions.length - 1; for (let i = 0, length = qualityOptions.length; i < length; i++) { const option = qualityOptions[i]; - if (selectedIndex === -1 && option.bitrate <= maxStreamingBitrate) { + if (option.bitrate > 0 && option.bitrate <= maxStreamingBitrate) { selectedIndex = i; + break; } } - if (selectedIndex === -1) { - selectedIndex = qualityOptions.length - 1; - } - const currentQualityOption = qualityOptions[selectedIndex]; if (!options.isAutomaticBitrateEnabled) {