Skip to content Skip to sidebar Skip to footer

App Can´t Play A Video From The Sd-card Despite The Fact That The Code Looks Fine

I use the code below to play a video from my SD-Card using Video View of Android. I placed a video file named Video.mp4 in the external storage root directory. But when starting my

Solution 1:

Replace

 Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/Video.mp4")

(which is invalid, since it lacks a scheme)

with:

Uri.fromFile(newFile(Environment.getExternalStorageDirectory(), "Video.mp4"))

Solution 2:

SOLUTION@all Solution to access the external SD-card:

v.setVideoURI(Uri.parse("/storage/sdcard1/testvideo.mp4")); 

instead of

v.setVideoURI(Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/testvideo.mp4")); 

REASON:

Environment.getExternalStorageDirectory().getPath() == "/storage/emulated/0"

Environment.getExternalStorageDirectory().getPath() delivers the path to an internal storage chip on my smartphone (HUAWEI P8) that is mounted like an SD-card but is not the external SD-card though.

Post a Comment for "App Can´t Play A Video From The Sd-card Despite The Fact That The Code Looks Fine"