So I know there are a lot of questions on this, but all seem to have the same answer and it's not what I'm looking for.
I have a video in the raw
folder in my project, and I can get it to play in my app with VideoView
. However, I would like to take advantage of the gallery video player that all phones come with so the user can pause or scroll through the video.
When I try to open my video with an ACTION_VIEW
intent, it appears that there are no apps that can handle the intent. I have the same video in a folder in my phone, and the gallery player can play it fine. I also downloaded VLC but still no apps show up in the list. Is it just not possible, or am I missing something?
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("android.resource://" + ActivityMain.PACKAGE_NAME + "/" + R.raw.test));
intent.setDataAndType(Uri.parse("android.resource://" + ActivityMain.PACKAGE_NAME + "/" + R.raw.test), "video/*");
startActivity(Intent.createChooser(intent, "Complete action using"));
Very few apps support the android.resource
scheme. Copy the video to a file and play that, or embed your own video player.
I think it should help you,use video/mp4
...
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"+R.raw. test);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);intent.setDataAndType(uri, "video/mp4");
startActivity(intent);
来源:https://stackoverflow.com/questions/42707272/android-play-video-in-raw-folder-launching-gallery-from-intent