From 6dcd5c4cf7efc8099d7ad68c2b14a13d6c48fafe Mon Sep 17 00:00:00 2001 From: Zyrouge Date: Thu, 14 Nov 2024 20:33:44 +0530 Subject: [PATCH] fix: radio getters --- .../io/github/zyrouge/symphony/services/radio/Radio.kt | 8 ++++---- .../zyrouge/symphony/services/radio/RadioObservatory.kt | 4 ++-- .../github/zyrouge/symphony/services/radio/RadioPlayer.kt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/github/zyrouge/symphony/services/radio/Radio.kt b/app/src/main/java/io/github/zyrouge/symphony/services/radio/Radio.kt index e8d26b6d..f3060cc8 100644 --- a/app/src/main/java/io/github/zyrouge/symphony/services/radio/Radio.kt +++ b/app/src/main/java/io/github/zyrouge/symphony/services/radio/Radio.kt @@ -53,10 +53,10 @@ class Radio(private val symphony: Symphony) : Symphony.Hooks { val hasPlayer get() = player?.usable == true val isPlaying get() = player?.isPlaying == true - val currentPlaybackPosition = player?.playbackPosition - val currentSpeed = player?.speed ?: RadioPlayer.DEFAULT_SPEED - val currentPitch = player?.pitch ?: RadioPlayer.DEFAULT_PITCH - val audioSessionId = player?.audioSessionId + val currentPlaybackPosition get() = player?.playbackPosition + val currentSpeed get() = player?.speed ?: RadioPlayer.DEFAULT_SPEED + val currentPitch get() = player?.pitch ?: RadioPlayer.DEFAULT_PITCH + val audioSessionId get() = player?.audioSessionId val onPlaybackPositionUpdate = Eventer() var persistedSpeed = RadioPlayer.DEFAULT_SPEED diff --git a/app/src/main/java/io/github/zyrouge/symphony/services/radio/RadioObservatory.kt b/app/src/main/java/io/github/zyrouge/symphony/services/radio/RadioObservatory.kt index 6f30851d..4ad4ce81 100644 --- a/app/src/main/java/io/github/zyrouge/symphony/services/radio/RadioObservatory.kt +++ b/app/src/main/java/io/github/zyrouge/symphony/services/radio/RadioObservatory.kt @@ -16,7 +16,7 @@ class RadioObservatory(private val symphony: Symphony) { val playbackPosition = _playbackPosition.asStateFlow() private val _queueIndex = MutableStateFlow(-1) val queueIndex = _queueIndex.asStateFlow() - private val _queue = MutableStateFlow>(emptyList()) + private val _queue = MutableStateFlow(emptyList()) val queue = _queue.asStateFlow() private val _loopMode = MutableStateFlow(RadioLoopMode.None) val loopMode = _loopMode.asStateFlow() @@ -24,7 +24,7 @@ class RadioObservatory(private val symphony: Symphony) { val shuffleMode = _shuffleMode.asStateFlow() private val _sleepTimer = MutableStateFlow(null) val sleepTimer = _sleepTimer.asStateFlow() - private val _pauseOnCurrentSongEnd = MutableStateFlow(false) + private val _pauseOnCurrentSongEnd = MutableStateFlow(false) val pauseOnCurrentSongEnd = _pauseOnCurrentSongEnd.asStateFlow() private val _speed = MutableStateFlow(RadioPlayer.DEFAULT_SPEED) val speed = _speed.asStateFlow() diff --git a/app/src/main/java/io/github/zyrouge/symphony/services/radio/RadioPlayer.kt b/app/src/main/java/io/github/zyrouge/symphony/services/radio/RadioPlayer.kt index f1bc8c7f..03d26b8f 100644 --- a/app/src/main/java/io/github/zyrouge/symphony/services/radio/RadioPlayer.kt +++ b/app/src/main/java/io/github/zyrouge/symphony/services/radio/RadioPlayer.kt @@ -36,7 +36,7 @@ class RadioPlayer(val symphony: Symphony, uri: Uri) { private var onError: RadioPlayerOnErrorListener? = null private var playbackPositionUpdater: Timer? = null - val playbackPosition: PlaybackPosition? + val playbackPosition get() = mediaPlayer?.let { try { PlaybackPosition(