Răsfoiți Sursa

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 ani în urmă
părinte
comite
37dfb5eb2c
1 a modificat fișierele cu 4 adăugiri și 2 ștergeri
  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() {