1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2026-04-22 23:01:22 +00:00

-Improved null checks in player stream resolution.

-Improved naming in MediaSourceManager
This commit is contained in:
John Zhen Mo
2017-10-29 12:39:53 -07:00
parent 52cdf96dfe
commit 0b1eda3050
4 changed files with 23 additions and 16 deletions

View File

@@ -272,17 +272,18 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.
}
@Override
@Nullable
public MediaSource sourceOf(final PlayQueueItem item, final StreamInfo info) {
final List<VideoStream> videos = ListHelper.getSortedStreamVideosList(context, info.video_streams, info.video_only_streams, false);
final VideoStream video;
final int index;
if (playbackQuality == null) {
final int index = getDefaultResolutionIndex(videos);
video = videos.get(index);
index = getDefaultResolutionIndex(videos);
} else {
final int index = getOverrideResolutionIndex(videos, getPlaybackQuality());
video = videos.get(index);
index = getOverrideResolutionIndex(videos, getPlaybackQuality());
}
if (index < 0 || index >= videos.size()) return null;
final VideoStream video = videos.get(index);
final MediaSource streamSource = buildMediaSource(video.url, MediaFormat.getSuffixById(video.format));
final AudioStream audio = ListHelper.getHighestQualityAudio(info.audio_streams);