From a5b4cf207d3942963d8d7553ec3d6cd36bdc41fc Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Thu, 9 Sep 2021 16:56:57 +0200 Subject: [PATCH] Prefer opus audio streams in listen mode --- src/invidious/views/components/player.ecr | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr index c3c02df0..82c89500 100644 --- a/src/invidious/views/components/player.ecr +++ b/src/invidious/views/components/player.ecr @@ -7,14 +7,14 @@ <% else %> <% if params.listen %> - <% # default to 128k m4a stream - best_m4a_stream_index = 0 - best_m4a_stream_bitrate = 0 + <% # default to 128k opus stream + best_opus_stream_index = 0 + best_opus_stream_bitrate = 0 audio_streams.each_with_index do |fmt, i| bandwidth = fmt["bitrate"].as_i - if (fmt["mimeType"].as_s.starts_with?("audio/mp4") && bandwidth > best_m4a_stream_bitrate) - best_m4a_stream_bitrate = bandwidth - best_m4a_stream_index = i + if (fmt["mimeType"].as_s.starts_with?("audio/webm") && bandwidth > best_opus_stream_bitrate) + best_opus_stream_bitrate = bandwidth + best_opus_stream_index = i end end @@ -25,7 +25,7 @@ bitrate = fmt["bitrate"] mimetype = HTML.escape(fmt["mimeType"].as_s) - selected = (i == best_m4a_stream_index) + selected = (i == best_opus_stream_index) %> <% if !params.local && !CONFIG.disabled?("local") %> -- 2.36.0