我正在使用视频播放器并希望在启动之前显示加载程序。以下是我的代码段。任何人都可以帮我解决这个问题吗?
showpDialog();
String ALLOWED_URI_CHARS = "@#&=*+-_.,:!?()/~'%";
String urlEncoded = Uri.encode(vid_path, ALLOWED_URI_CHARS);
System.out.println(urlEncoded);
final VideoView videoView =(VideoView) findViewById(R.id.vv);
videoView.setVideoPath(rlEncoded);
MediaController mediaController = new
MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.i("", "Duration = " +videoView.getDuration());
}
});
hidepDialog();
videoView.start();
答案 0 :(得分:1)
然后,在onCreate()
中,在致电runOnUiThread
之前,启动dialog
progressDialog = ProgressDialog.show(this, "", "Loading...", true);
设置OnPreparedListener()
,当视频准备好播放时,dialog
会关闭mVideoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer arg0) {
progressDialog.dismiss();
mVideoView.start();
}
});
saved