Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play audio in Kotlin Multiplatform (Desktop)?

Currently, I am Building a project using Kotlin Multiplatform. This project is only for Android and Desktop.

I want to play an audio file in this project. Can anyone help how I can do this? OR can anyone share some libraries that can do this task?

like image 379
SHUBHASAI MOHAPATRA Avatar asked Nov 02 '25 03:11

SHUBHASAI MOHAPATRA


1 Answers

EDIT - NEW ANSWER: I was so tired of not having a KMP library that I convinced my company to let me spend time building one.

basic-sound by LexiLabs is Kotlin MultiPlatform (KMP), supporting Android, Apple, WASM, and Javascript. It allows you to leverage the native media player libraries of each rather than building something from scratch every time. Also, you can contribute to the codebase since it is open source and actively maintained by myself.

ORIGINAL POST:

Korau is Kotlin MultiPlatform (KMP), and it's the only thing out there working at the moment.

If you're using a modern dependency structure for KMP, you'll add the following to your libs.versions.toml file:

[versions]
korau = "4.0.10"

[libraries]
korau = { module = "com.soywiz.korlibs.korau:korau", version.ref = "korau" }

and in your build.gradle.kts [shared] file, you'll put this:

kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation(libs.korau)
        }
    }
}

ADVISORY: The Korau library is stale. Their open source code is only reviewable as an archived zip in GitHub now, so no one has really been contributing to or looking at what's in it anymore besides a small circle of folks in the know at SoyWiz and KorGE.

like image 168
Robert Jamison Avatar answered Nov 04 '25 00:11

Robert Jamison