How do I parse a local video file embedded into sh...
# multiplatform
j
How do I parse a local video file embedded into shared module for iOS and Android? I am using ExoPlayer in Android and AvPlayer in iOS. At moment I only using web urls like https://. But is it possible give resources somehow smart agnostic between iOS and Android? I was thinking doing a delegate actual/expect, but if can use same String pattern for both but evaluate the actual path its fine. I have expect/actual anyway for the video player 🙂
j
On iOS, there's the URLForResource to access files in the bundle, but on Android, I'm not aware of any way how to access the file(s) in the bundle via any kind of "scheme://resource/identification". The easiest is to get a stream via openRawSerouce() there, and put the video in the res/raw. So you'll probably need to check if you can feed the player with a stream or buffer or bytes, and abstract this a bit accordingly...
j
On Android I know how to do 😛 Its very easy, depending if want local resources, R class references or something else. Also in my case want to use Jetbrains resources component library as much as possible, so I can put any file into that shared module directory resources and refer to it. I have the solution of NsURL in iOS and in Android using Uri, but need to lookup the dynamic file depending on platform.
For video player enough if I can refer to either web url or parsed URI referring to local file. For iOS doing like this:
Copy code
actual class MyPlatformResource(private val path: String): MyResource {

    @Composable
    override fun absolutePath(): String {
        return NSBundle.mainBundle.resourcePath + "/" + path
    }

    @Composable
    fun urlPath(): NSURL {
        return NSURL.fileURLWithPath(absolutePath())
    }
But just not sure which bundle Jetbrains plugin using for their painterResource variant, font and string references cross platform 😄