I’m trying to use the API DEMO **MediaPlayerDemo_Video.java*. I’m new to programming and trying to figure out how to set the path to a local video stored in the raw folder. Can someone provide how to reference this file? Thanks.
private void playVideo(Integer Media) {
doCleanUp();
try {
switch (Media) {
case LOCAL_VIDEO:
/*
* TODO: Set the path variable to a local media file path.
*/
path = "";
if (path == "") {
// Tell the user to provide a media file URL.
Toast
.makeText(
MediaPlayerDemo_Video.this,
"Please edit MediaPlayerDemo_Video Activity, "
+ "and set the path variable to your media file path."
+ " Your media file must be stored on sdcard.",
Toast.LENGTH_LONG).show();
}
You can open raw resources by using resource id. If the file name is “test.avi” then something like this should work:
But that is for reading the file, so if you want to open the file with media player then I think you should put it in SD card. Then you can get the path with:
EDIT:
Ok, I figured how to open a file in
rawfolder withMediaPlayer:Change this:
To this: