Skip to content

Commit

Permalink
Remove OPUS HLS streams from playable streams
Browse files Browse the repository at this point in the history
This format is not supported by ExoPlayer when returned as HLS streams, so we
can't play streams using this format and this delivery method.

Also improve the Javadoc of ListHelper.getPlayableStreams.
  • Loading branch information
AudricV committed Nov 15, 2023
1 parent 6d69451 commit e5fda35
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 e5fda35

Please # to comment.