Playing video files shared with a FileProvider doesn't work with VLC
I am developing an android app in which i am sharing video files using FileProvider.
The video files are stored in the files directory of the app (getFilesDir()) which is reserved to the app.
I am using a FileProvider to share the videos with the video players of the user's device. So that the user can play them with his video players.
The videos can be played with video players like the default one of android or MX Player. But when i try to play them with VLC it fails.
I declared the provider in the manifest like this :
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.vlcsharedfilebug.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/share_path" />
</provider>
To play the video i start an intent like this:
private static final String AUTHORITY = "com.vlcsharedfilebug.fileprovider";
File videoFile = new File(getAppMediaDir(), VIDEO_FILE_NAME);
Uri uri = FileProvider.getUriForFile(this, AUTHORITY, videoFile);
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setAction(Intent.ACTION_VIEW);
String mimeType = "video/mp4";
intent.setDataAndType(uri, mimeType);
List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(
intent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
I have attached to this ticket a demo app that shows this problem.
I am using the last version of VLC available on google play (Version 1.2.6)
Thank you for your help