Skip to content

Commit

Permalink
[stable-3.20] Correctly obey play/pause state (#10186)
Browse files Browse the repository at this point in the history
* Correctly obey play/pause state

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>

* PreviewVideoActivity: remove commented code

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>

Co-authored-by: tobiasKaminsky <tobias@kaminsky.me>
  • Loading branch information
AlvaroBrey and tobiasKaminsky authored May 6, 2022
1 parent 694392c commit bbf7238
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,10 @@ private void playVideoUri(final Uri uri) {
if (savedPlaybackPosition >= 0) {
exoPlayer.seekTo(savedPlaybackPosition);
}
exoPlayer.play();

if (autoplay) {
exoPlayer.play();
}
}

@Override
Expand Down Expand Up @@ -575,7 +578,6 @@ public void onPause() {
@Override
public void onResume() {
super.onResume();
autoplay = false;
if(getActivity() instanceof FileDisplayActivity){
((FileDisplayActivity) getActivity()).configureToolbarForMediaPreview(getFile());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class PreviewVideoActivity :
if (mSavedPlaybackPosition >= 0) {
exoPlayer?.seekTo(mSavedPlaybackPosition)
}

onIsPlayingChanged(exoPlayer!!.isPlaying)
}

override fun onIsPlayingChanged(isPlaying: Boolean) {
Expand Down Expand Up @@ -200,7 +202,10 @@ class PreviewVideoActivity :
private fun play(item: MediaItem) {
exoPlayer?.addMediaItem(item)
exoPlayer?.prepare()
exoPlayer?.play()

if (mAutoplay) {
exoPlayer?.play()
}
}

override fun onStart() {
Expand All @@ -220,6 +225,7 @@ class PreviewVideoActivity :
else -> MediaItem.fromUri(mStreamUri!!)
}
if (exoPlayer != null) {
setupPlayerView()
play(mediaItem)
} else {
val context = this
Expand Down

0 comments on commit bbf7238

Please sign in to comment.