Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play files stored in flutter assets #36

Open
andreasgangso opened this issue Aug 22, 2023 · 0 comments
Open

Play files stored in flutter assets #36

andreasgangso opened this issue Aug 22, 2023 · 0 comments

Comments

@andreasgangso
Copy link
Member

This is currently possible, at least on android, but very hard to use.
You need to start your url with asset:///flutter_assets/, so e.g. for "assets/demo.mp4", it would look like this:

  MediaItem(
    url: 'asset:///flutter_assets/assets/demo.mp4',
    mimeType: 'video/mp4',
    metadata: MediaMetadata(title: 'Asset file'),
  ),

Instead, we should implement something similar to video_player:

  1. add a way to signal that this is an asset file, e.g. add a UrlType in the MediaItem pigeon.
  2. on the native side, use something like (untested):
    // Android
    val path = FlutterInjector.instance().flutterLoader().getLookupKeyForAsset(mediaItem.url)
    val exoMediaItemUrl = "asset:///" + path;
    // iOS
    let assetKey = registrar?.lookupKey(forAsset: mediaItem.url)
    let path = Bundle.main.path(forResource: assetKey, ofType: nil)!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant