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.
This commit is contained in:
Malloc Voidstar 2024-03-11 23:43:20 -07:00
parent 32f8c9b6c4
commit a5bd3a4485
No known key found for this signature in database
GPG Key ID: C34BA7CBAF747755
1 changed files with 3 additions and 0 deletions

View File

@ -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(),