mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 02:17:43 +03:00
PreviewMediaFragment: stop video when stopping activity, and don't recreate existing player
This avoids multiple instances of the player opening when minimizing the app, for example. Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
c9018f8ba6
commit
686748dda2
1 changed files with 10 additions and 3 deletions
|
@ -305,9 +305,12 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|||
// bind to any existing player
|
||||
mediaPlayerServiceConnection.bind();
|
||||
|
||||
exoPlayer = new ExoPlayer.Builder(requireContext()).build();
|
||||
if (exoPlayer == null) {
|
||||
exoPlayer = new ExoPlayer.Builder(requireContext()).build();
|
||||
}
|
||||
binding.exoplayerView.setPlayer(exoPlayer);
|
||||
|
||||
|
||||
LinearLayout linearLayout = binding.exoplayerView.findViewById(R.id.exo_center_controls);
|
||||
|
||||
if (linearLayout.getChildCount() == 5) {
|
||||
|
@ -579,10 +582,14 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|||
@Override
|
||||
public void onStop() {
|
||||
Log_OC.v(TAG, "onStop");
|
||||
if (MimeTypeUtil.isAudio(getFile()) && !mediaPlayerServiceConnection.isPlaying()) {
|
||||
final OCFile file = getFile();
|
||||
if (MimeTypeUtil.isAudio(file) && !mediaPlayerServiceConnection.isPlaying()) {
|
||||
stopAudio();
|
||||
} else if (MimeTypeUtil.isVideo(file) && exoPlayer.isPlaying()) {
|
||||
savedPlaybackPosition = exoPlayer.getCurrentPosition();
|
||||
exoPlayer.pause();
|
||||
}
|
||||
|
||||
|
||||
mediaPlayerServiceConnection.unbind();
|
||||
toggleDrawerLockMode(containerActivity, DrawerLayout.LOCK_MODE_UNLOCKED);
|
||||
super.onStop();
|
||||
|
|
Loading…
Reference in a new issue