从 SD 卡播放视频并使用 videoView 循环播放视频

Play a video from SD card and loop the video using videoView

我的目标是播放 SDCard 中某个文件夹中的所有视频,例如下载文件夹中的所有视频并循环播放。但我现在的问题是当我启动应用程序时,应用程序总是显示错误 "Can't play this video".

这是我的代码,感谢您的帮助。

@Override
protected void onResume() {

    super.onResume();
    VideoView video = (VideoView) findViewById(R.id.videoview1);
    video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
        }
    });
    video.setVideoPath("/storage/extSdCard/Download/great.mp4");
    video.start();

}

检查代码可能对你有用。

  @Override
  protected void onResume() {
    super.onResume();
   Uri videoUri =Uri.fromFile(new File("/storage/extSdCard/Download/great.mp4")) 
    //set the uri of the video to be played 
    video.setVideoURI(videoUri);
    video.start();

    video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
        }
    });
}