feat: add the Kotlin Multiplatform AudioManager client
CI / test (push) Successful in 2m0s
CI / build (push) Successful in 13m27s

A shared Compose Multiplatform client for Android, desktop and web on the
native mood-first API.

- Bearer login with persisted, restorable sessions.
- Mood grid and full editor (create, settings, seeds, delete).
- Server-driven radio sessions with automatic started/completed/skipped
  events and prefetching.
- Add to current mood or choose another mood from the player.
- Library search, original MP3 downloads, offline playback of downloads.
- Offline cache of moods, songs and the last sync revision.
- Platform audio: Media3 on Android, MP3SPI on desktop, HTML audio on web.
- Platform storage: filesystem on Android/desktop, localStorage on web.
- Desktop tests for API parsing, errors and cache persistence.
- Gitea CI image with Android SDK 35, build pipeline and tagged releases.
This commit is contained in:
TapTap committed 2026-11-14 18:24:06 +00:00
commit 3281e46104
40 files changed
+7021

No files matched your search

@@ -0,0 +1,52 @@
package win.taptap.musicmanager.client
import kotlinx.browser.document
import org.w3c.dom.HTMLAudioElement
import win.taptap.musicmanager.client.api.Song
import win.taptap.musicmanager.client.playback.AudioPlayer
class WebAudioPlayer : AudioPlayer {
private val audio: HTMLAudioElement =
(document.createElement("audio") as HTMLAudioElement).apply {
preload = "auto"
}
override fun play(source: String, song: Song, local: Boolean) {
audio.src = source
audio.play()
}
override fun pause() {
audio.pause()
}
override fun resume() {
audio.play()
}
override fun stop() {
audio.pause()
audio.removeAttribute("src")
audio.load()
}
override fun isPlaying(): Boolean = !audio.paused && !audio.ended
override fun isFinished(): Boolean = audio.ended
override fun positionSeconds(): Double = audio.currentTime.takeIf { it.isFinite() } ?: 0.0
override fun durationSeconds(): Double =
audio.duration.takeIf { it.isFinite() && it > 0 } ?: 0.0
override val canSeek: Boolean = true
override fun seekTo(seconds: Double) {
audio.currentTime = seconds
}
override fun release() {
stop()
}
}