Am trying to play a video stored in the internal storage in Android. However, no matter what I do it keeps coming back with either a -1 error or a -38 error. Both seem to be rather generic errors hence are not much intelligible.
I am wondering if it is possible to use a VideoView and not a MediaPlayer instance to play a video file from the local storage.
The steps involved in my app include,
- downloading a file from a remote url
Storing the file in internal storage (note i use the convention for ensuring that it has global read permissions. i.e
openFileOutput(file_name, Context.MODE_WORLD_READABLE);
Reading the media file back at a later point from this location, and playing it in a videoView.
String filePath = "file://" + getFilesDir()+File.separator+file_name; Uri videoUri = Uri.parse(filePath); Log.d("Video Player", filePath); videoPlayer.setVideoURI(videoUri);
I also went through other links in StackOverflow which point out that I need to implement a CustomContentProvider to be able to read these files. Is there a direct way of accessing the file uri and setting it to the videoView without having to resorting to creating a custom content provider and using a mediaPlayer instead of a videoView.
Other StackOverflow references used