添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

[Android Platform]
I try to open video files when the user selects the 'openwith' button in Android device file manager and then select my app to play the video.
I tried some libraries to get the file uri . all of them gave me the same uri like "content://com.mi.android.globalfileexplorer.myprovider/external_files/Download/file_name.mp4" when i try open media file with :

final playable = Media(uri);
await player.open(playable);

it trows exception:

W/System.err(16859): java.io.FileNotFoundException: No content provider: content://com.mi.android.globalfileexplorer.myprovider/external_files/Download/file_name.mp4
W/System.err(16859): 	at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1994)
W/System.err(16859): 	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1823)
W/System.err(16859): 	at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1656)
W/System.err(16859): 	at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1603)
W/System.err(16859): 	at com.alexmercerind.mediakitandroidhelper.MediaKitAndroidHelper.openFileDescriptorJava(MediaKitAndroidHelper.java:43)

i tried libraries to convert the uri to file path

uri_content
uri_to_file

or other ways to get file of that :
File.fromUri(uri)
but all of them trows exception.
is there any way to play that uri ?

That's a content URI, you don't have permissions to it (or haven't requested them). You must learn about Android development e.g. permissions, scoped storage, storage access framework etc. It's entirely separate topic of discussion.

Off-Topic:

  • I implemented opening of file(s) (content://) through intents on Android in Harmonoid.
  • package:file_picker also locally caches file first. It's not possible to use content:// directly in Flutter.
  • As a cross-platform project, better is to work with more "universal" approaches.

    The content:// URI however, do work as intended, as long as you have permission:

  • [Enhancement][Android] content:// URI support #252
  • Probably declare & prompt new Android 13 permissions:

    https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions