feat(android): play in a foreground MediaSessionService
CI / build (push) Failing after 2m28s

Move ExoPlayer out of the activity into a MediaSessionService so audio keeps
playing when the app is backgrounded, the screen is off, or the task is
swiped away. Media3 provides the media notification, lock-screen and headset
controls, audio focus and noisy-headphone handling.

The UI talks to the service through a MediaController-backed AudioPlayer and
sends title, artist, album and artwork metadata for the notification. Add the
Android 13 notification permission request, the media playback foreground
service permissions, and wake mode for network streaming.
This commit is contained in:
TapTap committed 2026-11-14 21:52:03 +00:00
1 parent 9cdbb3702e
commit b8bbf8d07c
12 files changed
+232 -82

No files matched your search

@@ -9,7 +9,7 @@ import win.taptap.musicmanager.client.api.Song
* store polls [isFinished] because some backends have no callback support.
*/
interface AudioPlayer {
fun play(source: String, song: Song, local: Boolean)
fun play(source: String, song: Song, local: Boolean, artworkUri: String? = null)
fun pause()
fun resume()
fun stop()
@@ -696,7 +696,12 @@ class AppStore(
private fun startSong(song: Song) {
val localPath = storage.downloadPath(song.id)
finishing = false
player.play(localPath ?: api.streamUrl(song.id), song, localPath != null)
player.play(
source = localPath ?: api.streamUrl(song.id),
song = song,
local = localPath != null,
artworkUri = api.coverUrl(song.albumId),
)
startPolling()
}