【发布时间】:2014-04-07 12:30:00
【问题描述】:
我想在我的 Android 设备上的 VideoView 中播放我 sdcard 中的视频,但我总是收到 错误: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
视频位于我的SD卡/video/lvl1/documentariesandyou.mp4
视频兼容我从this post获取的。
如何在我的设备上播放电影?
【问题讨论】:
-
您好,请问如何解决这个问题?请更新答案。谢谢Mojo先生。
-
@HuyTower:我已将解决方案作为评论发布在标记的答案中。我的 SD 卡是从我的操作系统 (Ubuntu) 安装的,因此 Android 无法安装它。
-
这个
marked answer在哪里?这个“问题是我的操作系统(ubuntu)安装了存储,所以我无法访问sdcard上的文件!”???我不明白你说什么。与安卓设备无关?无需修改代码或权限,其他与Android设备相关的东西? -
是的,问题不在于代码,问题在于我已经在我的操作系统中安装了我的 SD 卡。在我从 Ubuntu 上卸载它后,它工作了
标签: android video android-mediaplayer android-sdcard android-videoview