Use a whitelist to filter all streams retrieved by the extractor.
NewPipe Extractor now extracts all YouTube Itags and therefore only those which can be handled by the player need to be retrieved from the list of all available streams.
This commit is contained in:
parent
727de29bd6
commit
672093ad7a
3 changed files with 36 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
|||
package org.schabi.newpipe.player.resolver;
|
||||
|
||||
import static org.schabi.newpipe.util.ListHelper.getNonTorrentStreams;
|
||||
import static org.schabi.newpipe.util.ListHelper.getPlayableStreams;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
|
@ -68,12 +68,12 @@ public class AudioPlaybackResolver implements PlaybackResolver {
|
|||
*/
|
||||
@Nullable
|
||||
private Stream getAudioSource(@NonNull final StreamInfo info) {
|
||||
final List<AudioStream> audioStreams = getNonTorrentStreams(info.getAudioStreams());
|
||||
final List<AudioStream> audioStreams = getPlayableStreams(info.getAudioStreams());
|
||||
if (!audioStreams.isEmpty()) {
|
||||
final int index = ListHelper.getDefaultAudioFormat(context, audioStreams);
|
||||
return getStreamForIndex(index, audioStreams);
|
||||
} else {
|
||||
final List<VideoStream> videoStreams = getNonTorrentStreams(info.getVideoStreams());
|
||||
final List<VideoStream> videoStreams = getPlayableStreams(info.getVideoStreams());
|
||||
if (!videoStreams.isEmpty()) {
|
||||
final int index = ListHelper.getDefaultResolutionIndex(context, videoStreams);
|
||||
return getStreamForIndex(index, videoStreams);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import java.util.Optional;
|
|||
|
||||
import static com.google.android.exoplayer2.C.TIME_UNSET;
|
||||
import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams;
|
||||
import static org.schabi.newpipe.util.ListHelper.getNonTorrentStreams;
|
||||
import static org.schabi.newpipe.util.ListHelper.getPlayableStreams;
|
||||
|
||||
public class VideoPlaybackResolver implements PlaybackResolver {
|
||||
private static final String TAG = VideoPlaybackResolver.class.getSimpleName();
|
||||
|
|
@ -72,8 +72,8 @@ public class VideoPlaybackResolver implements PlaybackResolver {
|
|||
|
||||
// Create video stream source
|
||||
final List<VideoStream> videoStreamsList = ListHelper.getSortedStreamVideosList(context,
|
||||
getNonTorrentStreams(info.getVideoStreams()),
|
||||
getNonTorrentStreams(info.getVideoOnlyStreams()), false, true);
|
||||
getPlayableStreams(info.getVideoStreams()),
|
||||
getPlayableStreams(info.getVideoOnlyStreams()), false, true);
|
||||
final int index;
|
||||
if (videoStreamsList.isEmpty()) {
|
||||
index = -1;
|
||||
|
|
@ -100,7 +100,7 @@ public class VideoPlaybackResolver implements PlaybackResolver {
|
|||
}
|
||||
|
||||
// Create optional audio stream source
|
||||
final List<AudioStream> audioStreams = getNonTorrentStreams(info.getAudioStreams());
|
||||
final List<AudioStream> audioStreams = getPlayableStreams(info.getAudioStreams());
|
||||
final AudioStream audio = audioStreams.isEmpty() ? null : audioStreams.get(
|
||||
ListHelper.getDefaultAudioFormat(context, audioStreams));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue