Library screen: an "All music" card with Shuffle all, which builds a local queue from every cached song so playback does not need a mood session. Player bar: a sleep timer with 15/30/45/60/90 minute presets. The shared store shows the countdown and pauses playback; on Android the pause is also scheduled inside the media service through a custom session command, so it still fires when the app is backgrounded or the task is swiped away. Playback errors from the platform player now surface in the UI instead of failing silently (for example when no audio device is available). Tests cover shuffle-all, the empty library, timer expiry and cancelling it.
This commit is contained in:
1 parent
f8953fb200
commit
c7c1d59b70
10 files changed
+478
-42
No files matched your search
+7
@@ -3,6 +3,7 @@ package win.taptap.musicmanager.client
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.common.MediaMetadata
|
||||
@@ -108,6 +109,12 @@ class MediaControllerAudioPlayer(context: Context) : AudioPlayer {
|
||||
withController { it.seekTo((seconds * 1000).toLong().coerceAtLeast(0L)) }
|
||||
}
|
||||
|
||||
override fun scheduleSleepTimer(seconds: Long?): Boolean {
|
||||
val current = controller ?: return false
|
||||
val args = Bundle().apply { putLong(SLEEP_TIMER_SECONDS, seconds ?: 0L) }
|
||||
return runCatching { current.sendCustomCommand(SLEEP_TIMER_COMMAND, args) }.isSuccess
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
controller?.release()
|
||||
MediaController.releaseFuture(future)
|
||||
|
||||
Reference in new issue
Block a user