I have resources placed in "resources" directory of the commonMain source set as mentioned here:
https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html#configuration
I can access them on Android using the following code for example as InputStream (or can use "resource" method with readBytes()):
applicationContext.javaClass.classLoader?.getResource("music.mp3")
This will get something like this as URL:
jar:file:/data/app/~~703PFoktDXUKZn5lPAVPA==/com.example.test-AtrtrkqGf82Y2vOReZF9Ew==/base.apk!/music.mp3
But I have problem with creating Android Uri which is needed for ExoPlayer and its MediaItem:
MediaItem.Builder().setUri(uri).build()
This will throw:
<http://sun.net|sun.net>.<http://www.protocol.jar.JarURLConnection|www.protocol.jar.JarURLConnection> cannot be cast to java.net.HttpURLConnection
Is there any solition other than copying the resource to the assets directory for Android?
It will be then accessible using:
Uri.parse(("file:///android_asset/music.mp3"))
Thanks