无法播放此视频

时间:2014-07-28 10:57:33

标签: android android-mediaplayer

当我想播放来自SD卡的视频无法播放此视频时会显示错误 代码是 公共类MainActivity扩展了Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    VideoView vv = (VideoView) findViewById(R.id.videoView);
    vv.setVideoPath("/sdcard/idayam.mp4");
    vv.setMediaController(new MediaController(this));
    vv.start();
    vv.requestFocus();
}

}我的LogCat错误是

07-28 16:52:26.874:E / MediaPlayer(23466):错误(1,-2147483648)

1 个答案:

答案 0 :(得分:1)

更改

vv.setVideoPath("/sdcard/idayam.mp4");

vv.setVideoPath(Environment.getExternalStorageDirectory().getAbsolutePath() + "/idayam.mp4");

您提供的路径不是有效路径。您应该始终使用Environment.getExternalStorageDirectory().getAbsolutePath()来获取SD卡的路径