PreviewMediaFragment: fix restoring seek position when returning from fullscreen stream

The stream asynctask was just ignoring the saved time

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2022-02-18 18:11:43 +01:00
parent 11e472b18b
commit 329dea57a3
No known key found for this signature in database
GPG key ID: 2585783189A62105

View file

@ -473,15 +473,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
// load the video file in the video player
// when done, VideoHelper#onPrepared() will be called
if (getFile().isDown()) {
binding.progress.setVisibility(View.GONE);
exoPlayer.addMediaItem(MediaItem.fromUri(getFile().getStorageUri()));
exoPlayer.prepare();
if (savedPlaybackPosition >= 0) {
exoPlayer.seekTo(savedPlaybackPosition);
}
exoPlayer.play();
playVideoUri(getFile().getStorageUri());
} else {
try {
new LoadStreamUrl(this, user, clientFactory).execute(getFile().getLocalId());
@ -491,6 +483,18 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
}
}
private void playVideoUri(final Uri uri) {
binding.progress.setVisibility(View.GONE);
exoPlayer.addMediaItem(MediaItem.fromUri(uri));
exoPlayer.prepare();
if (savedPlaybackPosition >= 0) {
exoPlayer.seekTo(savedPlaybackPosition);
}
exoPlayer.play();
}
@Override
public void onFullScreenModeChanged(boolean isFullScreen) {
Log_OC.e(TAG, "Fullscreen: " + isFullScreen);
@ -535,12 +539,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
if (previewMediaFragment != null && previewMediaFragment.binding != null && context != null) {
if (uri != null) {
previewMediaFragment.videoUri = uri;
previewMediaFragment.binding.progress.setVisibility(View.GONE);
previewMediaFragment.exoPlayer.addMediaItem(MediaItem.fromUri(uri));
previewMediaFragment.exoPlayer.prepare();
previewMediaFragment.exoPlayer.play();
previewMediaFragment.playVideoUri(uri);
} else {
previewMediaFragment.emptyListView.setVisibility(View.VISIBLE);
previewMediaFragment.setVideoErrorMessage(