1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 11:02:35 +01:00

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.
This commit is contained in:
AudricV 2023-11-15 22:52:57 +01:00
parent 6d694518fe
commit e5fda35c51
No known key found for this signature in database
GPG Key ID: DA92EC7905614198

View File

@ -189,13 +189,16 @@ public final class ListHelper {
/** /**
* Return a {@link Stream} list which only contains streams which can be played by the player. * 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}. * <p>
* Torrent streams are also removed, because they cannot be retrieved. * 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 <S> the item type's class that extends {@link Stream}
* @param streamList the original stream list * @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 * @return a stream list which only contains streams that can be played the player
*/ */
@NonNull @NonNull
@ -204,6 +207,8 @@ public final class ListHelper {
final int youtubeServiceId = YouTube.getServiceId(); final int youtubeServiceId = YouTube.getServiceId();
return getFilteredStreamList(streamList, return getFilteredStreamList(streamList,
stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT
&& (stream.getDeliveryMethod() != DeliveryMethod.HLS
|| stream.getFormat() != MediaFormat.OPUS)
&& (serviceId != youtubeServiceId && (serviceId != youtubeServiceId
|| stream.getItagItem() == null || stream.getItagItem() == null
|| SUPPORTED_ITAG_IDS.contains(stream.getItagItem().id))); || SUPPORTED_ITAG_IDS.contains(stream.getItagItem().id)));
@ -295,7 +300,9 @@ public final class ListHelper {
final Comparator<AudioStream> cmp = getAudioFormatComparator(context); final Comparator<AudioStream> cmp = getAudioFormatComparator(context);
for (final AudioStream stream : audioStreams) { for (final AudioStream stream : audioStreams) {
if (stream.getDeliveryMethod() == DeliveryMethod.TORRENT) { if (stream.getDeliveryMethod() == DeliveryMethod.TORRENT
|| (stream.getDeliveryMethod() == DeliveryMethod.HLS
&& stream.getFormat() == MediaFormat.OPUS)) {
continue; continue;
} }