Open armond-avanes opened 4 days ago
Hi @armond-avanes, you're correct that there is no dedicated API for resources. Would it be a solution to treat it as a raw Resource e.g.:
You place the audio file in the resources folder for raw files e.g. composeResources\files\sample.mp3
Get the resource URI and pass it to the library:
// val player = GadulkaPlayer()
val uri = Res.getUri("files/sample.mp3")
player.play(uri)
@kkostov That doesn't work because the underlying libraries (e.g. ExoPlayer on Android) are not designed to work with Compose Multiplatform resources.
I tested the approach above on Android, iOS and JVM and it seemed to work (not sure why, I think may be because of https://github.com/JetBrains/compose-multiplatform/pull/4965?), but perhaps it's not ideal for all situations.
You're definitely right that it makes sense to have a dedicated API using resources - it will make the interface of the library more accessible and easier to use so I will add it.
I'm looking for an API to be able to load audio files bundled with app. Or at least to be able to pass in a ByteArray of content to play. Looking into the docs and the source code, the only option was to play an online resource.