I was creating a simple app which stream videos from net and I made it but now I want to change the code so that I can play video files from my SDCard
original code:
The videoView.setVideoURI(vidFile);
method needs to be replaced by the videoView.setVideoPath(path);
method.
Here path specifies the path of the video file on the SDCARD
.
This path can be easily retrieved using the MediaStore.Video.Media.DATA
property of that video file or by just entering the songpath statically as /sdcard/songname
.
Uri vidFile = Uri.parse(
Environment.getExternalStorageDirectory().getAbsolutePath()+"filename");
...
the rest of the code will be same.
In place of
videoView.setVideoUri(vidFile)
use
videoView.setVideoPath("/sdcard/SONG.")
.
Let me know.
I also tried your code and got same error message but when I tried with video path with no blank space in path or name, it worked well. Just give it a try. e.g, file path "/mnt/sdcard/Movies/Long Drive Song - Khiladi 786 ft. Akshay Kumar_Asin-YouTube.mp4" gave the error but file path "/mnt/sdcard/Movies/Khiladi.mp4" worked well.
these links may help you:
Playing 3gp video in SD card of Android
how-play-video-and-audio-android
Using VideoView to play mp4 from sdcard