Skip to content

Commit

Permalink
Merge pull request #10579 from AudricV/exclude-hls-opus-streams-for-p…
Browse files Browse the repository at this point in the history
…layback

Remove OPUS HLS streams from playable streams
  • Loading branch information
Stypox authored Nov 16, 2023
2 parents 6d69451 + e5fda35 commit bf8890b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions app/src/main/java/org/schabi/newpipe/util/ListHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ public static <S extends Stream> List<S> getUrlAndNonTorrentStreams(

/**
* Return a {@link Stream} list which only contains streams which can be played by the player.
* <br>
* Some formats are not supported. For more info, see {@link #SUPPORTED_ITAG_IDS}.
* Torrent streams are also removed, because they cannot be retrieved.
*
* <p>
* Some formats are not supported, see {@link #SUPPORTED_ITAG_IDS} for more details.
* Torrent streams are also removed, because they cannot be retrieved, like OPUS streams using
* HLS as their delivery method, since they are not supported by ExoPlayer.
* </p>
*
* @param <S> the item type's class that extends {@link Stream}
* @param streamList the original stream list
* @param serviceId
* @param serviceId the service ID from which the streams' list comes from
* @return a stream list which only contains streams that can be played the player
*/
@NonNull
Expand All @@ -204,6 +207,8 @@ public static <S extends Stream> List<S> getPlayableStreams(
final int youtubeServiceId = YouTube.getServiceId();
return getFilteredStreamList(streamList,
stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT
&& (stream.getDeliveryMethod() != DeliveryMethod.HLS
|| stream.getFormat() != MediaFormat.OPUS)
&& (serviceId != youtubeServiceId
|| stream.getItagItem() == null
|| SUPPORTED_ITAG_IDS.contains(stream.getItagItem().id)));
Expand Down Expand Up @@ -295,7 +300,9 @@ public static List<AudioStream> getFilteredAudioStreams(
final Comparator<AudioStream> cmp = getAudioFormatComparator(context);

for (final AudioStream stream : audioStreams) {
if (stream.getDeliveryMethod() == DeliveryMethod.TORRENT) {
if (stream.getDeliveryMethod() == DeliveryMethod.TORRENT
|| (stream.getDeliveryMethod() == DeliveryMethod.HLS
&& stream.getFormat() == MediaFormat.OPUS)) {
continue;
}

Expand Down

0 comments on commit bf8890b

Please sign in to comment.