Parcourir la source

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

yattoz il y a 2 ans
Parent
révision
c5c4bdd838
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  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 Voir le fichier

@@ -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
     }