我想在我的Android设备上使用我的SD卡播放视频,但我总是得到错误:1,-2147483648 。我的代码如下所示:
private VideoView video_view;
private MediaController ctlr;
//define video and play it if it exists
File clip = new File(Environment.getExternalStorageDirectory().getPath()
+feed.getStep(current_step).getPathToVideo());
if (clip.exists()) {
Log.d(TAG, "Video exists");
video_view.setVideoPath(clip.getAbsolutePath());
ctlr = new MediaController(this);
ctlr.setMediaPlayer(video_view);
video_view.setMediaController(ctlr);
video_view.requestFocus();
video_view.start();
}else{
Log.d(TAG, "Video DOES NOT exist, path is: "+Environment.getExternalStorageDirectory()
.getPath()+feed.getStep(current_step).getPathToVideo());
}
在LogCat中,我得到了这个输出:
Video DOES NOT exist, path is: /storage/sdcard0/video/lvl1/documentariesandyou.mp4
视频位于/video/lvl1/documentariesandyou.mp4
视频兼容我从this post获取了它。
如何在设备上播放电影?
答案 0 :(得分:0)
getAbsolutePath()
,而不仅仅是getPath()
。