Skip to content

Commit e5fda35

Browse files
committed
Remove OPUS HLS streams from playable streams
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.
1 parent 6d69451 commit e5fda35

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

app/src/main/java/org/schabi/newpipe/util/ListHelper.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,16 @@ public static <S extends Stream> List<S> getUrlAndNonTorrentStreams(
189189

190190
/**
191191
* Return a {@link Stream} list which only contains streams which can be played by the player.
192-
* <br>
193-
* Some formats are not supported. For more info, see {@link #SUPPORTED_ITAG_IDS}.
194-
* Torrent streams are also removed, because they cannot be retrieved.
192+
*
193+
* <p>
194+
* Some formats are not supported, see {@link #SUPPORTED_ITAG_IDS} for more details.
195+
* Torrent streams are also removed, because they cannot be retrieved, like OPUS streams using
196+
* HLS as their delivery method, since they are not supported by ExoPlayer.
197+
* </p>
195198
*
196199
* @param <S> the item type's class that extends {@link Stream}
197200
* @param streamList the original stream list
198-
* @param serviceId
201+
* @param serviceId the service ID from which the streams' list comes from
199202
* @return a stream list which only contains streams that can be played the player
200203
*/
201204
@NonNull
@@ -204,6 +207,8 @@ public static <S extends Stream> List<S> getPlayableStreams(
204207
final int youtubeServiceId = YouTube.getServiceId();
205208
return getFilteredStreamList(streamList,
206209
stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT
210+
&& (stream.getDeliveryMethod() != DeliveryMethod.HLS
211+
|| stream.getFormat() != MediaFormat.OPUS)
207212
&& (serviceId != youtubeServiceId
208213
|| stream.getItagItem() == null
209214
|| SUPPORTED_ITAG_IDS.contains(stream.getItagItem().id)));
@@ -295,7 +300,9 @@ public static List<AudioStream> getFilteredAudioStreams(
295300
final Comparator<AudioStream> cmp = getAudioFormatComparator(context);
296301

297302
for (final AudioStream stream : audioStreams) {
298-
if (stream.getDeliveryMethod() == DeliveryMethod.TORRENT) {
303+
if (stream.getDeliveryMethod() == DeliveryMethod.TORRENT
304+
|| (stream.getDeliveryMethod() == DeliveryMethod.HLS
305+
&& stream.getFormat() == MediaFormat.OPUS)) {
299306
continue;
300307
}
301308

0 commit comments

Comments
 (0)