Fixes of VideoDetailFragment

This commit is contained in:
Avently 2020-01-10 17:32:05 +03:00
parent 6fc91312d2
commit 421b8214cb
2 changed files with 19 additions and 18 deletions

View file

@ -874,7 +874,7 @@ public class VideoDetailFragment
} }
StackItem currentPeek = stack.peek(); StackItem currentPeek = stack.peek();
if (currentPeek != null && currentPeek.getPlayQueue() != playQueue) { if (currentPeek != null && !currentPeek.getPlayQueue().equals(playQueue)) {
// When user selected a stream but didn't start playback this stream will not be added to backStack. // When user selected a stream but didn't start playback this stream will not be added to backStack.
// Then he press Back and the last saved item from history will show up // Then he press Back and the last saved item from history will show up
setupFromHistoryItem(currentPeek); setupFromHistoryItem(currentPeek);
@ -1091,8 +1091,7 @@ public class VideoDetailFragment
startService(true); startService(true);
return; return;
} }
if (currentInfo == null || playQueue == null) if (currentInfo == null) return;
return;
PlayQueue queue = setupPlayQueueForIntent(false); PlayQueue queue = setupPlayQueueForIntent(false);
@ -1120,7 +1119,6 @@ public class VideoDetailFragment
// Size can be 0 because queue removes bad stream automatically when error occurs // Size can be 0 because queue removes bad stream automatically when error occurs
if (playQueue == null || playQueue.size() == 0) if (playQueue == null || playQueue.size() == 0)
queue = new SinglePlayQueue(currentInfo); queue = new SinglePlayQueue(currentInfo);
this.playQueue = queue;
return queue; return queue;
} }
@ -1404,8 +1402,7 @@ public class VideoDetailFragment
super.handleResult(info); super.handleResult(info);
currentInfo = info; currentInfo = info;
setInitialData(info.getServiceId(), info.getOriginalUrl(), info.getName(), setInitialData(info.getServiceId(), info.getOriginalUrl(), info.getName(), playQueue);
playQueue == null ? new SinglePlayQueue(info) : playQueue);
if(showRelatedStreams){ if(showRelatedStreams){
if(null == relatedStreamsLayout){ //phone if(null == relatedStreamsLayout){ //phone
@ -1665,8 +1662,13 @@ public class VideoDetailFragment
restoreDefaultOrientation(); restoreDefaultOrientation();
break; break;
case BasePlayer.STATE_PLAYING: case BasePlayer.STATE_PLAYING:
if (positionView.getAlpha() != 1f) animateView(positionView, true, 100); if (positionView.getAlpha() != 1f
if (detailPositionView.getAlpha() != 1f) animateView(detailPositionView, true, 100); && player.getPlayQueue() != null
&& player.getPlayQueue().getItem() != null
&& player.getPlayQueue().getItem().getUrl().equals(url)) {
animateView(positionView, true, 100);
animateView(detailPositionView, true, 100);
}
setupOrientation(); setupOrientation();
break; break;
} }
@ -1677,7 +1679,8 @@ public class VideoDetailFragment
// Progress updates every second even if media is paused. It's useless until playing // Progress updates every second even if media is paused. It's useless until playing
if (!player.getPlayer().isPlaying() || playQueue == null) return; if (!player.getPlayer().isPlaying() || playQueue == null) return;
if (playQueue == player.getPlayQueue()) showPlaybackProgress(currentProgress, duration); if (player.getPlayQueue().getItem().getUrl().equals(url))
showPlaybackProgress(currentProgress, duration);
// We don't want to interrupt playback and don't want to see notification if player is stopped // We don't want to interrupt playback and don't want to see notification if player is stopped
// since next lines of code will enable background playback if needed // since next lines of code will enable background playback if needed
@ -1907,9 +1910,8 @@ public class VideoDetailFragment
if (player != null && player.isInFullscreen()) showSystemUi(); if (player != null && player.isInFullscreen()) showSystemUi();
break; break;
case BottomSheetBehavior.STATE_DRAGGING: case BottomSheetBehavior.STATE_DRAGGING:
if (player != null && player.isControlsVisible()) player.hideControls(0, 0);
break;
case BottomSheetBehavior.STATE_SETTLING: case BottomSheetBehavior.STATE_SETTLING:
if (player != null && player.isControlsVisible()) player.hideControls(0, 0);
break; break;
} }
} }

View file

@ -510,7 +510,7 @@ public class VideoPlayerImpl extends VideoPlayer
@Override @Override
protected void initPlayback(@NonNull PlayQueue queue, int repeatMode, float playbackSpeed, float playbackPitch, boolean playbackSkipSilence, boolean playOnReady) { protected void initPlayback(@NonNull PlayQueue queue, int repeatMode, float playbackSpeed, float playbackPitch, boolean playbackSkipSilence, boolean playOnReady) {
super.initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence, playOnReady); super.initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence, playOnReady);
updateQueue(queue); updateQueue();
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -1474,7 +1474,6 @@ public class VideoPlayerImpl extends VideoPlayer
public void setFragmentListener(PlayerServiceEventListener listener) { public void setFragmentListener(PlayerServiceEventListener listener) {
fragmentListener = listener; fragmentListener = listener;
updateMetadata();
updatePlayback(); updatePlayback();
triggerProgressUpdate(); triggerProgressUpdate();
} }
@ -1498,12 +1497,12 @@ public class VideoPlayerImpl extends VideoPlayer
} }
} }
private void updateQueue(PlayQueue queue) { private void updateQueue() {
if (fragmentListener != null) { if (fragmentListener != null && playQueue != null) {
fragmentListener.onQueueUpdate(queue); fragmentListener.onQueueUpdate(playQueue);
} }
if (activityListener != null) { if (activityListener != null && playQueue != null) {
activityListener.onQueueUpdate(queue); activityListener.onQueueUpdate(playQueue);
} }
} }