diff --git a/app/src/main/java/org/schabi/newpipe/player/resolver/AudioPlaybackResolver.java b/app/src/main/java/org/schabi/newpipe/player/resolver/AudioPlaybackResolver.java index 036df51dd..e1d3af335 100644 --- a/app/src/main/java/org/schabi/newpipe/player/resolver/AudioPlaybackResolver.java +++ b/app/src/main/java/org/schabi/newpipe/player/resolver/AudioPlaybackResolver.java @@ -68,12 +68,14 @@ public class AudioPlaybackResolver implements PlaybackResolver { */ @Nullable private Stream getAudioSource(@NonNull final StreamInfo info) { - final List audioStreams = getPlayableStreams(info.getAudioStreams()); + final List audioStreams = getPlayableStreams( + info.getAudioStreams(), info.getServiceId()); if (!audioStreams.isEmpty()) { final int index = ListHelper.getDefaultAudioFormat(context, audioStreams); return getStreamForIndex(index, audioStreams); } else { - final List videoStreams = getPlayableStreams(info.getVideoStreams()); + final List videoStreams = getPlayableStreams( + info.getVideoStreams(), info.getServiceId()); if (!videoStreams.isEmpty()) { final int index = ListHelper.getDefaultResolutionIndex(context, videoStreams); return getStreamForIndex(index, videoStreams); diff --git a/app/src/main/java/org/schabi/newpipe/player/resolver/VideoPlaybackResolver.java b/app/src/main/java/org/schabi/newpipe/player/resolver/VideoPlaybackResolver.java index c3303266a..0017312cf 100644 --- a/app/src/main/java/org/schabi/newpipe/player/resolver/VideoPlaybackResolver.java +++ b/app/src/main/java/org/schabi/newpipe/player/resolver/VideoPlaybackResolver.java @@ -72,8 +72,8 @@ public class VideoPlaybackResolver implements PlaybackResolver { // Create video stream source final List videoStreamsList = ListHelper.getSortedStreamVideosList(context, - getPlayableStreams(info.getVideoStreams()), - getPlayableStreams(info.getVideoOnlyStreams()), false, true); + getPlayableStreams(info.getVideoStreams(), info.getServiceId()), + getPlayableStreams(info.getVideoOnlyStreams(), info.getServiceId()), false, true); final int index; if (videoStreamsList.isEmpty()) { index = -1; @@ -100,7 +100,8 @@ public class VideoPlaybackResolver implements PlaybackResolver { } // Create optional audio stream source - final List audioStreams = getPlayableStreams(info.getAudioStreams()); + final List audioStreams = getPlayableStreams( + info.getAudioStreams(), info.getServiceId()); final AudioStream audio = audioStreams.isEmpty() ? null : audioStreams.get( ListHelper.getDefaultAudioFormat(context, audioStreams)); diff --git a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java index f36866025..389bcc84f 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java @@ -1,5 +1,7 @@ package org.schabi.newpipe.util; +import static org.schabi.newpipe.extractor.ServiceList.YouTube; + import android.content.Context; import android.content.SharedPreferences; import android.net.ConnectivityManager; @@ -162,16 +164,19 @@ public final class ListHelper { * Some formats are not supported. For more info, see {@link #SUPPORTED_ITAG_IDS}. * Torrent streams are also removed, because they cannot be retrieved. * - * @param streamList the original stream list * @param the item type's class that extends {@link Stream} + * @param streamList the original stream list + * @param serviceId * @return a stream list which only contains streams that can be played the player */ @NonNull public static List getPlayableStreams( - @Nullable final List streamList) { + @Nullable final List streamList, final int serviceId) { + final int youtubeServiceId = YouTube.getServiceId(); return getFilteredStreamList(streamList, stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT - && (stream.getItagItem() == null + && (serviceId != youtubeServiceId + || stream.getItagItem() == null || SUPPORTED_ITAG_IDS.contains(stream.getItagItem().id))); }