public class MainActivity extends AppCompatActivity {
private VideoView videoView;
private PopupWindow pw;
private View viewById;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = findViewById(R.id.player);
viewById = findViewById(R.id.view);
videoView.setUrl("https://mysdev.obs.cn-east-2.myhuaweicloud.com:443/video/2022/12/22/e290b6640387a1c149f504013895bbed.mp4"); //设置视频地址
StandardVideoController controller = new StandardVideoController(this);
controller.addDefaultControlComponent("标题", false);
videoView.setVideoController(controller); //设置控制器
videoView.start(); //开始播放,不调用则不自动播放
findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showEditPhotoWindow();
}
});
}
private void showEditPhotoWindow() {
View contentView = getLayoutInflater().inflate(R.layout.my_pop, null,false);
pw = new PopupWindow(contentView, getWindowManager().getDefaultDisplay().getWidth(), dip2px(this,300), true);
pw.setBackgroundDrawable(new ColorDrawable());
pw.showAsDropDown(viewById);
initView(contentView);
}
private void initView(View contentView) {
TextView tv1 = contentView.find