0

Hi i want to play a video file but after showing video it is showing error that can't play video file i am using Video view and path of video is

Uri uri=Uri.parse(Environment.getRootDirectory().getPath()+"/Phone storage/video.mp4");

Can some help me how to play video file that is store on my phone

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
Kishor Joshi
  • 47
  • 1
  • 2
  • 5

3 Answers3

1

You should use Uri.fromFile instead of Uri.parse

Greg Ennis
  • 14,917
  • 2
  • 69
  • 74
1

Create "raw" folder in "res", copy your video file to raw folder, in your code you should to do that :

String UrlPath = "android.resource://" + getPackageName() + "/"
+ R.raw.your_video_name;
Uri video_uri = Uri.parse(UrlPath);
video.setVideoURI(video_uri);
video.setMediaController(new MediaController(this));
video.requestFocus();
video.start();
Nguyen Thanh An
  • 269
  • 1
  • 4
  • 12
0

Try out this way:

Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+"Phone storage"+File.separator+"video.mp4");
GrIsHu
  • 29,068
  • 10
  • 64
  • 102