Hi,
I am displaying a VideoView in a custom Dialog I am creating. I am
attaching a MediaController to the VideoView, but the MediaController
won't show up when touching/clicking the screen or VideoView on a
device or in the emulator. Below is my code for creating the Dialog:

  private Dialog createFullScreenVideoDialog(final Bundle args){
    //Create Layout...
    FrameLayout holder = new FrameLayout(this);
    holder.setId(holder.hashCode());
    holder.setLayoutParams(new
ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));

    //Create video view
    final VideoView video = new VideoView(this);
    video.setId(video.hashCode());
    FrameLayout.LayoutParams videoParams = null;
    switch(getResources().getConfiguration().orientation){
    case Configuration.ORIENTATION_LANDSCAPE:
      videoParams = new
FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.FILL_PARENT, Gravity.CENTER);
      break;
    case Configuration.ORIENTATION_PORTRAIT:
      videoParams = new
FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT, Gravity.CENTER);
      break;
    default: //If the orientation is ORIENTATION_SQUARE or
ORIENTATION_UNDEFINED
      //or some other value...
      videoParams = new
FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, Gravity.CENTER);
    }

    holder.addView(video, videoParams);

    final Dialog dia = new
Dialog(this,android.R.style.Theme_NoTitleBar_Fullscreen){
      public void onBackPressed(){
        video.pause();
        super.onBackPressed();
      }
    };

    dia.setContentView(holder);

    dia.setOnShowListener(new OnShowListener() {

      @Override
      public void onShow(DialogInterface arg0) {
        String path =
args.getString(ComponentConstants.VIDEOPLAYER_FULLSCREEN_PATHKEY);

        MediaController controller = new
MediaController(dia.getContext());
        video.setMediaController(controller);
        if(path!=null){
          try {
            video.setVideoURI(MediaUtil.getVideoPath(getActiveForm(),
path));
 
if(args.getBoolean(ComponentConstants.VIDEOPLAYER_FULLSCREEN_STATEKEY))
{
              video.start();
 
video.seekTo(args.getInt(ComponentConstants.VIDEOPLAYER_FULLSCREEN_CURRENTPOSITIONKEY));
            }
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    });
    return dia;
  }

The video is playing in the VideoView, but I can't see the
MediaController.

Any ideas?
Thanks,
Vance

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to