Skip to content

"No such file or directory" when using Res.getUri() #4877

@hekirekiissen

Description

@hekirekiissen

Describe the bug
I was developing multiplatform audio player using MediaPlayer for Android, AVAudioPlayer for iOS. I used new resource api Res.getUri() to get URI of the mp3 file.

actual class AudioPlayer actual constructor(uri: String) {
    private val mediaPlayer = MediaPlayer().apply {
        setDataSource(MainActivity.appContext, uri.toUri())
        prepare()
    }

    actual fun play() = mediaPlayer.start()
}
val audioPlayer = AudioPlayer(Res.getUri("files/Sample.mp3"))

iOS works fine. By the way, there is an issue with Android:

Failed to open file 'jar:file:/data/app/~~iN2KoRgBjEr0KuRV7TmyrT==/com.example.audioplayer-1F2AEdsqRz5PTffEv0pF3t==/base.apk!/files/Sample.mp3'. (No such file or directory)

Affected platforms

  • Android(Compose multiplatform resource issue)

Versions

  • Libraries:
    • Compose Multiplatform version: 1.6.10
  • Kotlin version: 1.9.23

Metadata

Metadata

Assignees

Labels

questionNot a bug, but question or commentresources

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions