|
@@ -499,6 +499,7 @@ class RadioService : MediaBrowserServiceCompat() {
|
499
|
499
|
.setUsage(C.USAGE_ALARM)
|
500
|
500
|
.build()
|
501
|
501
|
} else {
|
|
502
|
+ isAlarmStopped = true // if we're not ringing and it tries playing, it means the user opened the app somehow
|
502
|
503
|
audioAttributes.setUsage(AudioAttributesCompat.USAGE_MEDIA)
|
503
|
504
|
audioFocusRequestBuilder.setAudioAttributes(audioAttributes.build())
|
504
|
505
|
audioFocusRequest = audioFocusRequestBuilder.build()
|
|
@@ -514,11 +515,6 @@ class RadioService : MediaBrowserServiceCompat() {
|
514
|
515
|
return
|
515
|
516
|
}
|
516
|
517
|
|
517
|
|
- // TODO: Remove this
|
518
|
|
- if (mediaSession.controller.playbackState.state == PlaybackStateCompat.STATE_PLAYING && !isRinging && isAlarmStopped)
|
519
|
|
- return // nothing to do here
|
520
|
|
- isAlarmStopped = true
|
521
|
|
-
|
522
|
518
|
PlayerStore.instance.playbackState.value = PlaybackStateCompat.STATE_PLAYING
|
523
|
519
|
|
524
|
520
|
// Reinitialize media player. Otherwise the playback doesn't resume when beginPlaying. Dunno why.
|
|
@@ -534,7 +530,6 @@ class RadioService : MediaBrowserServiceCompat() {
|
534
|
530
|
}
|
535
|
531
|
|
536
|
532
|
// START PLAYBACK, LET'S ROCK
|
537
|
|
- player.playWhenReady = true
|
538
|
533
|
nowPlayingNotification.update(this, isUpdatingNotificationButton = true, isRinging = isRinging)
|
539
|
534
|
|
540
|
535
|
playbackStateBuilder.setState(
|
|
@@ -544,6 +539,8 @@ class RadioService : MediaBrowserServiceCompat() {
|
544
|
539
|
SystemClock.elapsedRealtime()
|
545
|
540
|
)
|
546
|
541
|
mediaSession.setPlaybackState(playbackStateBuilder.build())
|
|
542
|
+ player.playWhenReady = true
|
|
543
|
+
|
547
|
544
|
//[REMOVE LOG CALLS]Log.d(tag, radioTag + "begin playing")
|
548
|
545
|
}
|
549
|
546
|
|
|
@@ -557,8 +554,8 @@ class RadioService : MediaBrowserServiceCompat() {
|
557
|
554
|
{
|
558
|
555
|
if (mediaSession.controller.playbackState.state == PlaybackStateCompat.STATE_STOPPED)
|
559
|
556
|
return // nothing to do here
|
560
|
|
-
|
561
|
|
- isAlarmStopped = true
|
|
557
|
+ if (PlayerStore.instance.playbackState.value == PlaybackStateCompat.STATE_PLAYING)
|
|
558
|
+ isAlarmStopped = true
|
562
|
559
|
|
563
|
560
|
PlayerStore.instance.playbackState.value = PlaybackStateCompat.STATE_STOPPED
|
564
|
561
|
|