I want to play a video file in videoview which is displayed inside a dialog and on completion the dialog box should be closed . I read about doing it through media controller so I have the following:
final Dialog dialog = new Dialog(MyActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.MyCustomLayoutWithVideoView);
    dialog.show();
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    lp.copyFrom(dialog.getWindow().getAttributes());
    dialog.getWindow().setAttributes(lp);
    final VideoView videoview = (VideoView) dialog.findViewById(R.id.videoView);
    Uri uri = Uri.parse(SoundFile);
    **MediaController mc = new MediaController(this);
    videoview.setMediaController(mc);**
        videoview.start();
    videoview.setVideoURI(uri);
    videoview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) 
{
Toast.makeText(getApplicationContext(), "Msg", Toast.LENGTH_LONG).show();
        }
    });
1) The part of declaring mediacontroller is wrong.. it cant get context, what is the context?
2) How can control this dialog's size based on the maximum height and weight?
 
    