Browse Source

rollback change related to alarm playback, fix stutter when changing tab

yattoz 2 years ago
parent
commit
c5c4bdd838
1 changed files with 5 additions and 1 deletions
  1. 5 1
      app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt

+ 5 - 1
app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt View File

@@ -514,6 +514,10 @@ class RadioService : MediaBrowserServiceCompat() {
514 514
         if (result != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
515 515
             return
516 516
         }
517
+        if (mediaSession.controller.playbackState.state == PlaybackStateCompat.STATE_PLAYING && !isRinging && isAlarmStopped)
518
+        {
519
+            return //nothing to do here
520
+        }
517 521
 
518 522
         PlayerStore.instance.playbackState.value = PlaybackStateCompat.STATE_PLAYING
519 523
 
@@ -530,6 +534,7 @@ class RadioService : MediaBrowserServiceCompat() {
530 534
         }
531 535
 
532 536
         // START PLAYBACK, LET'S ROCK
537
+        player.playWhenReady = true
533 538
         nowPlayingNotification.update(this, isUpdatingNotificationButton =  true, isRinging = isRinging)
534 539
 
535 540
         playbackStateBuilder.setState(
@@ -539,7 +544,6 @@ class RadioService : MediaBrowserServiceCompat() {
539 544
             SystemClock.elapsedRealtime()
540 545
         )
541 546
         mediaSession.setPlaybackState(playbackStateBuilder.build())
542
-        player.playWhenReady = true
543 547
 
544 548
         //[REMOVE LOG CALLS]Log.d(tag, radioTag + "begin playing")
545 549
     }