dialog與videoview結合,實現懸浮播放效果
阿新 • • 發佈:2019-02-01
MyVideoView vv = new MyVideoView(ch.this);
vv.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.video));
//vv.setMediaController(new MediaController(ch.this));
final Dialog menuDialog = new Dialog(ch.this,R.style.AlertDialogCustom);
final Dialog videoDialog = new Dialog(ch.this,R.style.AlertDialogCustom);
videoDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉dialog的標題
videoDialog.setContentView(vv);
Window mwindow = videoDialog.getWindow();
WindowManager.LayoutParams lp = mwindow.getAttributes();
lp.x = 10;
lp.y = 70;
lp.height=400;
lp.width=400;
mwindow.setAttributes(lp);
videoDialog.show();
vv.start();
vv.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
videoDialog.dismiss();
}
});
vv.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.video));
//vv.setMediaController(new MediaController(ch.this));
final Dialog menuDialog = new Dialog(ch.this,R.style.AlertDialogCustom);
final Dialog videoDialog = new Dialog(ch.this,R.style.AlertDialogCustom);
videoDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉dialog的標題
videoDialog.setContentView(vv);
Window mwindow = videoDialog.getWindow();
WindowManager.LayoutParams lp = mwindow.getAttributes();
lp.x = 10;
lp.y = 70;
lp.height=400;
lp.width=400;
mwindow.setAttributes(lp);
videoDialog.show();
vv.start();
vv.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
videoDialog.dismiss();
}
});