判断SD卡中的视频文件是否存在

private void prepareData() {
	// 视频文件路径
//	final String videopath = "/mnt/sdcard/girl.3gp";
	final String videopath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/girl.3gp";
		
	File f = new File(videopath);
		
	if(f.exists()){
		mVideoView.setVideoPath(videopath);

		mVideoView.start();

		// 播放设置
		mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

		@Override
		public void onPrepared(MediaPlayer mp) {
			mp.start();
			// if (progress != null)
			// progress.dismiss();
			mp.setLooping(true);
			}
		});
	} else {
		finish();
		return;
	}

	// mVideoView.setOnCompletionListener(new
	// MediaPlayer.OnCompletionListener() {
	//
	// @Override
	// public void onCompletion(MediaPlayer mp) {
	// mVideoView.setVideoPath(videopath);
	// mVideoView.start();
	// }
	// });
}

这个是我写的循环播放sd卡里视频的代码

    原文作者:Dijkstra算法
    原文地址: https://blog.csdn.net/bsmmaoshenbo/article/details/41935367
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞