Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,7 @@ private static PlayQueue getPlayQueueFromCache(@NonNull final Intent intent) {
if (queueCache == null) {
return null;
}
final PlayQueue newQueue = SerializedCache.getInstance().take(queueCache, PlayQueue.class);
if (newQueue == null) {
return null;
}
return newQueue;
return SerializedCache.getInstance().take(queueCache, PlayQueue.class);
}

private void initUIsForCurrentPlayerType() {
Expand Down Expand Up @@ -2041,7 +2037,7 @@ public MediaSource sourceOf(final PlayQueueItem item, final StreamInfo info) {
// resolver was called when the app was in background, the app will only stream audio when
// the user come back to the app and will never fetch the video stream.
// Note that the video is not fetched when the app is in background because the video
// renderer is fully disabled (see useVideoSource method), except for HLS streams
// renderer is fully disabled (see useVideoAndSubtitles method), except for HLS streams
// (see https://github.com/google/ExoPlayer/issues/9282).
return videoResolver.resolve(info);
}
Expand Down Expand Up @@ -2214,13 +2210,24 @@ public void useVideoAndSubtitles(final boolean videoAndSubtitlesEnabled) {

isAudioOnly = !videoAndSubtitlesEnabled;

final var item = playQueue.getItem();
final boolean hasPendingRecovery =
item != null && item.getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET;
final boolean hasTimeline =
!exoPlayerIsNull() && !simpleExoPlayer.getCurrentTimeline().isEmpty();


getCurrentStreamInfo().ifPresentOrElse(info -> {
// In case we don't know the source type, fall back to either video-with-audio, or
// audio-only source type
final SourceType sourceType = videoResolver.getStreamSourceType()
.orElse(SourceType.VIDEO_WITH_AUDIO_OR_AUDIO_ONLY);

setRecovery(); // making sure to save playback position before reloadPlayQueueManager()
if (hasTimeline || !hasPendingRecovery) {
// making sure to save playback position before reloadPlayQueueManager()
setRecovery();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if conditions I added are supposed to ensure setRecovery is only called when there is no pending recovery (it won't be overwriting a recovery position that's already been set), or when exoplayer is far along in it's setup so that there's stuff to play (timeline is not empty).

Hm, setRecovery() is called anyway here, independently from whether a recovery position was already set or not.. Don't you need to remove the first call? This is at least what I understood from your detailed explanation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lmao my bad, this a git issue, seems the rebasing I did onto dev didn't actually end up as it showed in Android Studio. Above setRecovery is not supposed to be there x).

I've confirmed this doesn't actually work with the above setRecovery still in place. I've removed it now


if (playQueueManagerReloadingNeeded(sourceType, info, getVideoRendererIndex())) {
reloadPlayQueueManager();
Expand All @@ -2234,6 +2241,10 @@ The current metadata may be null sometimes (for e.g. when using an unstable conn
index of the video renderer or playQueueManagerReloadingNeeded returns true
*/
setRecovery(); // making sure to save playback position before reloadPlayQueueManager()
if (hasTimeline || !hasPendingRecovery) {
// making sure to save playback position before reloadPlayQueueManager()
setRecovery();
}
Comment thread
TobiGr marked this conversation as resolved.
reloadPlayQueueManager();
});

Expand Down