Android: how to play video from assets?
Instead of accessing from assests,You must 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.
VideoView view = (VideoView)findViewById(R.id.videoView);
String path = "android.resource://" + getPackageName() + "/" + R.raw.video_file;
view.setVideoURI(Uri.parse(path));
view.start();
How to load videos from assets folder? (to play them with VideoView)
I don't know how to load videos from the assets folder. But I know how to load them from the /res/raw/ folder:
String uriPath = "android.resource://yourapplicationpackage/raw/videofilenamewithoutextension";
Uri uri = Uri.parse(uriPath);
video.setVideoURI(uri);
Trying to play video from raw folder (VideoView)
I had the same problem.
This worked for me:
Uri video = Uri.parse("android.resource://com.pac.myapp/raw/master");
So as you see you have 3 parts of the uri: 1) "android.resource://" 2) "com.pac.myapp" 3) "/raw/master"
"master" is the name of your video
Related Topics
Android: Keeping a Background Service Alive (Preventing Process Death)
How to Set a Gradient Background in a Material Button from Material Components
Viewpager as a Circular Queue/Wrapping
Too Many Field References: 70613; Max Is 65536
What Does Google-Services.JSON Really Do
Locationclient Getlastlocation() Return Null
How to Set a Reminder in Android
Notificationcompat.Builder Deprecated in Android O
"Gradle Version 2.10 Is Required." Error
How to Center Text Horizontally and Vertically in a Textview
How to Execute Async Task Repeatedly After Fixed Time Intervals
How to Pass the Values from One Activity to Previous Activity
Google Sign in Failed Com.Google.Android.Gms.Common.Api.Apiexception: 10: