Please help, How to play videos in android device from raw folder for offline mode?
Successful example1: I can play the video from SDcard used the below code.
Intent intent = new Intent(Intent.ACTION_VIEW);
String type = "video/mp4";
Uri uri = Uri.parse("file:///sdcard/test.mp4");
intent.setDataAndType(uri, type);
startActivity(intent);
Failed example2: Question: May I put the test.mp4 to res/raw folder?
Intent intent = new Intent(Intent.ACTION_VIEW);
String type = "video/mp4";
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.taipei);
intent.setDataAndType(uri, type);
startActivity(intent);
Have anyone can help me? Please.
Check this solution How to play videos in android from assets folder or raw folder?
This Solution will exactly helps you that what you want.
Copy the video into your project's res/raw folder. Create raw folder under res folder. It must be in a supported format (3gp, wmv, mp4 ) and named with lower case, numerics, underscores and dots in its filename likewise:video_file.mp4.
Create videoView in your xml file.
i think , everyone gave an answer, but doesn't explain the scenario. The main problem here is, If im not mistaken , Android assume that the video coming from your SD Card is dynamic, where in it could be possible , that the format is not supported or supported, thus it enables / ask you to select or open for other third party media software.
While anything you play UNDER RAW folder, requires a handler such as videoview or built in media player which leads to conclusion that anything you put in your RAW folder should be supported / readable by the Android OS.
However , the thread starter here wants that his RAW files , to be played using a third party media player.
I struggled with this for dynamic video names. The solution that worked for me was:
And in XML