From 06374c82fd920bdc340e3e3fd66ba23b55eea887 Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Tue, 5 Jun 2018 23:48:44 -0700 Subject: [PATCH] -Fixed video players end screen not cleared on restarting playback after single stream play queue is completed. --- .../schabi/newpipe/player/VideoPlayer.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 73f5e94b1..679fc6645 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -315,14 +315,13 @@ public abstract class VideoPlayer extends BasePlayer } captionPopupMenu.setOnDismissListener(this); } - /*////////////////////////////////////////////////////////////////////////// - // Playback Listener - //////////////////////////////////////////////////////////////////////////*/ - protected abstract VideoPlaybackResolver.QualityResolver getQualityResolver(); - protected void onMetadataChanged(@NonNull final MediaSourceTag tag) { - super.onMetadataChanged(tag); + private void updateStreamRelatedViews() { + if (getCurrentMetadata() == null) return; + + final MediaSourceTag tag = getCurrentMetadata(); + final StreamInfo metadata = tag.getMetadata(); qualityTextView.setVisibility(View.GONE); playbackSpeedTextView.setVisibility(View.GONE); @@ -330,7 +329,7 @@ public abstract class VideoPlayer extends BasePlayer playbackEndTime.setVisibility(View.GONE); playbackLiveSync.setVisibility(View.GONE); - switch (tag.getMetadata().getStreamType()) { + switch (metadata.getStreamType()) { case AUDIO_STREAM: surfaceView.setVisibility(View.GONE); endScreen.setVisibility(View.VISIBLE); @@ -350,8 +349,8 @@ public abstract class VideoPlayer extends BasePlayer break; case VIDEO_STREAM: - final StreamInfo info = tag.getMetadata(); - if (info.getVideoStreams().size() + info.getVideoOnlyStreams().size() == 0) break; + if (metadata.getVideoStreams().size() + metadata.getVideoOnlyStreams().size() == 0) + break; availableStreams = tag.getSortedAvailableVideoStreams(); selectedStreamIndex = tag.getSelectedVideoStreamIndex(); @@ -368,6 +367,16 @@ public abstract class VideoPlayer extends BasePlayer buildPlaybackSpeedMenu(); playbackSpeedTextView.setVisibility(View.VISIBLE); } + /*////////////////////////////////////////////////////////////////////////// + // Playback Listener + //////////////////////////////////////////////////////////////////////////*/ + + protected abstract VideoPlaybackResolver.QualityResolver getQualityResolver(); + + protected void onMetadataChanged(@NonNull final MediaSourceTag tag) { + super.onMetadataChanged(tag); + updateStreamRelatedViews(); + } @Override @Nullable @@ -400,6 +409,8 @@ public abstract class VideoPlayer extends BasePlayer public void onPlaying() { super.onPlaying(); + updateStreamRelatedViews(); + showAndAnimateControl(-1, true); playbackSeekBar.setEnabled(true);