这是我的 videoview 代码
try {
// Start the MediaController
MediaController mediacontroller = new MediaController(
SingleItemView.this);
mediacontroller.setAnchorView(videoview);
// Get the URL from String VideoURL
videoview.setMediaController(mediacontroller);
videoview.setVideoURI(Uri.parse(video));
videoview.requestFocus();
videoview.setKeepScreenOn(true);
videoview
.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
// Close the progress bar and play the video
public void onPrepared(MediaPlayer mediaPlayer) {
mProgressDialog.dismiss();
videoview.start();
}
});
} catch (Exception e) {
mProgressDialog.dismiss();
Log.e("Error", e.getMessage());
e.printStackTrace();
}
但如果视频流不工作,对话框仍然存在。
如果视频不工作,我想把对话放回主要活动..
我怎样才能做到这一点?
我尝试放置对话框但仍然无法正常工作我不知道为什么..
提前致谢 :)
编辑:我也尝试这样但仍然无法正常工作
try {
// Start the MediaController
MediaController mediacontroller = new MediaController(
SingleTrackActivity.this);
mediacontroller.setAnchorView(videoview);
// Get the URL from String VideoURL
videoview.setMediaController(mediacontroller);
videoview.setVideoURI(Uri.parse(duration));
videoview.requestFocus();
videoview.setKeepScreenOn(true);
videoview
.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
// Close the progress bar and play the video
public void onPrepared(
MediaPlayer mediaPlayer) {
pDialog.dismiss();
videoview.start();
}
});
} catch (Exception e) {
AlertDialog alertDialog = new AlertDialog.Builder(
SingleTrackActivity.this).create();
// Setting Dialog Title
alertDialog.setTitle("Alert Dialog");
// Setting Dialog Message
alertDialog.setMessage("Video Play Error :"
+ e.toString());
pDialog.dismiss();
System.out.println("Video Play Error :" + e.toString());
finish();
}