在Dialog里面播放视频
package com.cdc.dialogvideoview;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.VideoView;
public class MainActivity extends Activity {
private VideoView mVideoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mVideoView = new VideoView(this);
mVideoView.setVideoPath("http://192.168.0.115:8080/15074.mp4");
Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉dialog的标题
dialog.setContentView(mVideoView);
Window mwindow = dialog.getWindow();
WindowManager.LayoutParams lp = mwindow.getAttributes();
lp.x = 100;
lp.y = 100;
lp.height = 200;
lp.width = 300;
mwindow.setAttributes(lp);
dialog.show();
mVideoView.start();
}
}