From a5bd3a448516def2b187ae20b1e0d483aaa51462 Mon Sep 17 00:00:00 2001 From: Malloc Voidstar <1284317+AlyoshaVasilieva@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:43:20 -0700 Subject: [PATCH] Sort audio bitrates When a user sets a resolution manually, the player seems to select the first matching track. Sort audio bitrates so that highest quality is first to avoid low quality audio. --- src/main/java/me/kavin/piped/utils/CollectionUtils.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/me/kavin/piped/utils/CollectionUtils.java b/src/main/java/me/kavin/piped/utils/CollectionUtils.java index f2b4399..a36d79c 100644 --- a/src/main/java/me/kavin/piped/utils/CollectionUtils.java +++ b/src/main/java/me/kavin/piped/utils/CollectionUtils.java @@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamType; +import java.util.Comparator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -74,6 +75,8 @@ public class CollectionUtils { metaInfoItem.getUrls(), metaInfoItem.getUrlTexts() ))); + audioStreams.sort(Comparator.comparingInt((PipedStream stream) -> stream.bitrate).reversed()); + return new Streams(info.getName(), info.getDescription().getContent(), info.getTextualUploadDate(), info.getUploaderName(), substringYouTube(info.getUploaderUrl()), getLastThumbnail(info.getUploaderAvatars()), getLastThumbnail(info.getThumbnails()), info.getDuration(),