Discussion:
MediaController not visible for VideoView in Dialog
Vance Turnewitsch
2012-06-25 21:13:11 UTC
Permalink
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 android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Swap
2013-02-25 23:32:42 UTC
Permalink
hello,
Is your problem of mediacontroller is solve?
Post by Vance Turnewitsch
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
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){
videoParams = new
FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.FILL_PARENT, Gravity.CENTER);
break;
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 android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Imran khan
2016-02-22 06:27:34 UTC
Permalink
WindowManager.LayoutParams a = dialog.getWindow().getAttributes();a.dimAmount = 0;
dialog.getWindow().setAttributes(a);

use this my solve the problem
Post by Vance Turnewitsch
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
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){
videoParams = new
FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.FILL_PARENT, Gravity.CENTER);
break;
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 unsubscribe from this group and stop receiving emails from it, send an email to android-developers+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/19ec2800-6cb6-4458-882a-3ab3086e91ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...