Files
AudioManagerClient/composeApp/build.gradle.kts
T
TapTap b8bbf8d07c
CI / build (push) Failing after 2m28s
feat(android): play in a foreground MediaSessionService
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.
2026-11-14 21:52:03 +00:00

120 lines
3.5 KiB
Kotlin

@file:OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("org.jetbrains.compose")
id("org.jetbrains.kotlin.plugin.compose")
id("com.android.application")
}
kotlin {
androidTarget {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
jvm("desktop") {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
wasmJs {
outputModuleName.set("composeApp")
browser {
commonWebpackConfig {
outputFileName = "composeApp.js"
}
}
binaries.executable()
}
sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.materialIconsExtended)
implementation(compose.ui)
implementation("io.ktor:ktor-client-core:3.1.2")
implementation("io.ktor:ktor-client-content-negotiation:3.1.2")
implementation("io.ktor:ktor-serialization-kotlinx-json:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
}
commonTest.dependencies {
implementation(kotlin("test"))
implementation("io.ktor:ktor-client-mock:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1")
}
androidMain.dependencies {
implementation("io.ktor:ktor-client-okhttp:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1")
implementation("androidx.activity:activity-compose:1.10.1")
implementation("androidx.media3:media3-exoplayer:1.6.1")
implementation("androidx.media3:media3-common:1.6.1")
implementation("androidx.media3:media3-session:1.6.1")
}
val desktopMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
implementation("io.ktor:ktor-client-cio:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.10.1")
implementation("com.googlecode.soundlibs:mp3spi:1.9.5.4")
}
}
val wasmJsMain by getting {
dependencies {
implementation("io.ktor:ktor-client-js:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-browser:0.3")
}
}
}
}
android {
namespace = "win.taptap.musicmanager.client"
compileSdk = 35
defaultConfig {
applicationId = "win.taptap.musicmanager.client"
minSdk = 26
targetSdk = 35
versionCode = 1
versionName = "0.1.0"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
compose.desktop {
application {
mainClass = "win.taptap.musicmanager.client.MainKt"
nativeDistributions {
targetFormats(TargetFormat.Deb, TargetFormat.Dmg, TargetFormat.Msi)
packageName = "AudioManager"
packageVersion = "1.0.0"
}
}
}