这是indexloc提供的服务,不要输入任何密码
Skip to content

Support for playing Kotlin Multiplatform resources #1405

@Woren

Description

@Woren

Use case description

Main use case is about playing files inside APK with not only for example Uri:
Uri.parse(("file:///android_asset/music.mp3"))

But to be able to use files located in jar archive. For example Uri:
jar:file:/data/app/~~4hhLse7uFXE7V7sA==/com.example.composetest-jD6eQ3BeyvfQ==/base.apk!/composeResources/com.example.shared.resources/files/music.mp3

This approache can be used for multiplatform applications (e.i. multiplatform media players using AVPlayer on iOS and Exoplayer on Android with shared code) using Compose Multiplatform which will generated resources Uri for files inside common/shared directory. Mentioned directory "android_asset" is not accessible on iOS and generated resources Uri can't be used on Android. Media files needs to be duplicated to proper platform dependend directories.

More about Compose Multiplatform resources:
https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html

Proposed solution

Be able to use following code:
val mediaItem = MediaItem.Builder().setUri(Res.getUri("files/music.mp3")).build()

Alternatives considered

Only solution I can think of is using custom MediaSource and handling InputStream using method from Compose Multiplatform:
Res.readBytes("files/music.mp3")
with solution mentioned for example here (Exoplayer issue)
Similar issue is opened in Compose Multiplatform repository here and support from this side is not coming. The reasons are mentioned there.

Thank you for consideration!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions