From ac431e3ece282bc941ce5330d7e83bd8963dd50c Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Sun, 25 Feb 2018 15:32:25 -0800 Subject: [PATCH] -Fixed failed media source not treated as ready. --- .../newpipe/player/mediasource/FailedMediaSource.java | 2 -- .../schabi/newpipe/player/playback/MediaSourceManager.java | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/mediasource/FailedMediaSource.java b/app/src/main/java/org/schabi/newpipe/player/mediasource/FailedMediaSource.java index c4a44f503..2454c022c 100644 --- a/app/src/main/java/org/schabi/newpipe/player/mediasource/FailedMediaSource.java +++ b/app/src/main/java/org/schabi/newpipe/player/mediasource/FailedMediaSource.java @@ -4,10 +4,8 @@ import android.support.annotation.NonNull; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.source.MediaPeriod; -import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.upstream.Allocator; -import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.playlist.PlayQueueItem; import java.io.IOException; diff --git a/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java b/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java index 8d822fa54..50b485cb5 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java +++ b/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java @@ -219,13 +219,16 @@ public class MediaSourceManager { //////////////////////////////////////////////////////////////////////////*/ private boolean isPlayQueueReady() { + if (playQueue == null) return false; + final boolean isWindowLoaded = playQueue.size() - playQueue.getIndex() > windowSize; return playQueue.isComplete() || isWindowLoaded; } + // Checks if the current playback media source is a placeholder, if so, then it is not ready private boolean isPlaybackReady() { - return sources.getSize() > 0 && - sources.getMediaSource(playQueue.getIndex()) instanceof LoadedMediaSource; + return sources != null && playQueue != null && sources.getSize() > playQueue.getIndex() && + !(sources.getMediaSource(playQueue.getIndex()) instanceof PlaceholderMediaSource); } private void tryBlock() {