Trying to play a video located in R.raw. I have an xml array that I get the file that is to be played. The video works fine if I hardcode it, like this:
VideoView myVideoView = (VideoView)findViewById(R.id.videoview0);
myVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName()+"/"+R.raw.test));
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();
However, if I fetch the video from my array, my Error listener sets of and the video do not play. The string that is parsed is excatly the same as the above. This is how I do it (code modified for simplicity):
String uriParse = "android.resource://" + getPackageName() +"/R.raw." + getResources().getResourceEntryName(xmlArr.getResourceId(intVideoToPlay));
myVideoView.setVideoURI(Uri.parse(uriParse));
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();
My xml-array looks like this:
string-array name="arrTest"
item>@raw/test1 /item
item>@raw/test2 /item
item>@raw/test3 /item
/string-array