From cbe5d3889e554321d5a8868316833d973b713f5a Mon Sep 17 00:00:00 2001 From: alperozturk Date: Fri, 26 Jul 2024 13:36:15 +0200 Subject: [PATCH 1/4] Check existence of file Signed-off-by: alperozturk --- .../android/ui/preview/PreviewMediaActivity.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt index 19dead13fa8c..2d258215e9e7 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt @@ -749,16 +749,16 @@ class PreviewMediaActivity : override fun onStop() { Log_OC.v(TAG, "onStop") - val file = file - if (MimeTypeUtil.isAudio(file) && mediaPlayerServiceConnection?.isPlaying == false) { - stopAudio() - } else if (MimeTypeUtil.isVideo(file) && exoPlayer != null && exoPlayer?.isPlaying == true) { - savedPlaybackPosition = exoPlayer?.currentPosition ?: 0L - exoPlayer?.pause() + file?.let { + if (MimeTypeUtil.isAudio(it) && mediaPlayerServiceConnection?.isPlaying == false) { + stopAudio() + } else if (MimeTypeUtil.isVideo(it) && exoPlayer != null && exoPlayer?.isPlaying == true) { + savedPlaybackPosition = exoPlayer?.currentPosition ?: 0L + exoPlayer?.pause() + } } mediaPlayerServiceConnection?.unbind() - super.onStop() } From f7f2cdcd4f6930b0f26cc9c47e0814b2588286da Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 30 Jul 2024 10:53:18 +0200 Subject: [PATCH 2/4] No need file type check to stop exoPlayer, service Signed-off-by: alperozturk --- .../owncloud/android/ui/preview/PreviewMediaActivity.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt index 2d258215e9e7..1d5d3e4e4c6d 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt @@ -750,14 +750,13 @@ class PreviewMediaActivity : Log_OC.v(TAG, "onStop") file?.let { - if (MimeTypeUtil.isAudio(it) && mediaPlayerServiceConnection?.isPlaying == false) { - stopAudio() - } else if (MimeTypeUtil.isVideo(it) && exoPlayer != null && exoPlayer?.isPlaying == true) { + if (MimeTypeUtil.isVideo(it) && exoPlayer != null && exoPlayer?.isPlaying == true) { savedPlaybackPosition = exoPlayer?.currentPosition ?: 0L - exoPlayer?.pause() } } + exoPlayer?.pause() + stopAudio() mediaPlayerServiceConnection?.unbind() super.onStop() } From f13e41d102a259a46dfe03975130df9a10b52a76 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 30 Jul 2024 10:58:37 +0200 Subject: [PATCH 3/4] No need file type check to stop exoPlayer, service Signed-off-by: alperozturk --- .../com/owncloud/android/ui/preview/PreviewMediaActivity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt index 1d5d3e4e4c6d..62876683955d 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt @@ -755,7 +755,11 @@ class PreviewMediaActivity : } } - exoPlayer?.pause() + + if (exoPlayer?.isPlaying == true) { + exoPlayer?.pause() + } + stopAudio() mediaPlayerServiceConnection?.unbind() super.onStop() From 0d69db1528d9b6ee645af8ec5862846951b27406 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 30 Jul 2024 11:00:31 +0200 Subject: [PATCH 4/4] No need file type check to stop exoPlayer, service Signed-off-by: alperozturk --- .../com/owncloud/android/ui/preview/PreviewMediaActivity.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt index 62876683955d..1d5d3e4e4c6d 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt @@ -755,11 +755,7 @@ class PreviewMediaActivity : } } - - if (exoPlayer?.isPlaying == true) { - exoPlayer?.pause() - } - + exoPlayer?.pause() stopAudio() mediaPlayerServiceConnection?.unbind() super.onStop()