我使用以下代码在自定义提醒对话框中显示视频,但媒体控制器未显示在自定义提醒对话框视频视图中。
private void playvideo() {
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
dialog.setContentView(R.layout.playvideo);
dialog.show();
/*WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.copyFrom(dialog.getWindow().getAttributes());
dialog.getWindow().setAttributes(lp);*/
WindowManager.LayoutParams a = dialog.getWindow().getAttributes();
a.dimAmount = 0;
dialog.getWindow().setAttributes(a);
MediaController mc = new MediaController(dialog.getContext());
getWindow().setFormat(PixelFormat.TRANSLUCENT);
final VideoView videoview = (VideoView) dialog.findViewById(R.id.surface_view);
Uri uri = Uri.parse(fileData2.toString());
videoview.setVideoURI(uri);
videoview.setMediaController(mc);
mc.setAnchorView(videoview);
videoview.start();
ImageView playvideoclose=(ImageView)dialog.findViewById(R.id.playvideoclose);
playvideoclose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
videoview.stopPlayback();
dialog.dismiss();
}
});
}
请事先帮助我。