Browse Source

Player: don't try to pause a non-running media player

Fixes an issue triggered by pausing, and then minimizing and coming back to the app.

Right now state is still lost (file returns to the beginning) but as a stopgap it's OK.
In the future, the state machine and how it interacts with the fragment should be reworked.

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
Álvaro Brey Vilas 3 năm trước cách đây
mục cha
commit
37dfb5eb2c
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      src/main/java/com/nextcloud/client/media/Player.kt

+ 4 - 2
src/main/java/com/nextcloud/client/media/Player.kt

@@ -152,8 +152,10 @@ internal class Player(
 
         override fun onPausePlayback() {
             trace("onPausePlayback()")
-            mediaPlayer?.pause()
-            listener?.onPause()
+            if (mediaPlayer?.isPlaying == true) {
+                mediaPlayer?.pause()
+                listener?.onPause()
+            }
         }
 
         override fun onRequestFocus() {