I'm trying to play a video which is loaded in the res/raw folder. I've put it in res/raw/ but I'getting "MediaPlayer: Couldn't open" when I click on the button to play the video.
I think the issue is with how I am referencing the video, or there may be something I need to change in a manifest file. is there something obvious that I'm doing wrong?
The code is the following:
public void playVideo(View v) {
MediaController m = new MediaController(this);
vid.setMediaController(m);
//String path = "android.resource://" + getPackageName() + "+R.raw.hellologanhd";
String path = "/Users/xxxx/AndroidStudioProjects/HelloLogan/app/src/main/res/raw/hellologanhd";
System.out.println("path = "+ path);
Log.d("State", "Video Path: "+ path);
Uri u = Uri.parse(path);
vid.setVideoURI(u);
vid.start();
}
The file is located below in the src
The logs are showing the following, I've use logging to check the the variable is correct, I've swapped around the variable also, to check my referencing to it is correct.
2020-08-25 09:43:30.700 30392-30392/com.example.hellologan D/State: Video Path: /Users/xxxx/AndroidStudioProjects/HelloLogan/app/src/main/res/raw/hellologanhd 2020-08-25 09:43:30.710 30392-30392/com.example.hellologan W/MediaPlayer: Couldn't open /Users/xxxx/AndroidStudioProjects/HelloLogan/app/src/main/res/raw/hellologanhd: java.io.FileNotFoundException: No content provider: /Users/xxxx/AndroidStudioProjects/HelloLogan/app/src/main/res/raw/hellologanhd 2020-08-25 09:43:30.711 30392-30392/com.example.hellologan W/VideoView: Unable to open content: /Users/xxxx/AndroidStudioProjects/HelloLogan/app/src/main/res/raw/hellologanhd java.io.IOException: setDataSource failed.
This is what I am using as a guide: https://technobyte.org/using-mediaplayer-play-pause-stop-audio-file-android/