I can play a video from the Internet by inserting the URL like below:
mPath = Uri.parse("http://commonsware.com/misc/test2.3gp");
mVid.setVideoURI(mPath);
mVid.requestFocus();
mVid.start();
But now I have a video in my raw folder so the path is res/raw/testing.3gp. The code below doesn't work, and I've tried some other ways too to no avail.
mPath = Uri.parse("../../res/raw/testing.3gp");
Any suggestions?
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.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 3 − Create a new android resource folder(raw) and copy-paste your video file in that folder.
Step 2: Open your android studio go to the app > res > right-click > New > Android Resource Directory as shown in the below image. Step 3: Then a pop-up screen will arise like below. Here in Resource type choose raw.
Tap the video you'd like to watch. At the bottom of the video player, tap full screen .
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
this works for me
String videoName = nameWithoutFileExtention;
int id = getResources().getIdentifier(videoName, "raw", getActivity().getPackageName());
final String path = "android.resource://" + getActivity().getPackageName() + "/" + id;
vvBgVideo.setVideoURI(Uri.parse(path));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With