I'm positioning a VideoView with AbsoluteLayout (I need to display it on several places into the screen at specific positions).
public void showVideo(RectF bounds, final String videoUrl) {
AbsoluteLayout.LayoutParams params = (AbsoluteLayout.LayoutParams) video.getLayoutParams();
params.width = (int) bounds.width();
params.height = (int) bounds.height();
params.x = (int) bounds.left;
params.y = (int) bounds.top;
video.requestLayout();
video.setVisibility(View.VISIBLE);
video.setFocusable(true);
video.setFocusableInTouchMode(true);
video.requestFocus();
File file = new File(videoUrl);
video.setVideoPath(file.getAbsolutePath());
video.start();
}
But the Video ins't getting resized to the bounds I specified.
Any tips?
Another related question is, how to make the MediaController show over the VideoView?
After you change your
LayoutParams
I think you will need to callsetLayoutParams
so the layout can be updated with the new params. After the call tosetLayoutParams
you may have to call the methodreqestLayout
to invalidate the layout and trigger a redraw of the view.You will need to create a new instance of the
MediaController
and use the methodsetMediaController
on theVideoView
object.this is very close to what you are trying. if you are willing to subclass the videoview and
override onMeasure
here is the solution. you need tohttps://stackoverflow.com/questions/4434027/android-videoview-orientation-change-with-buffered-video/4452597#4452597
as for showing MediaController over VidowView
Declare
OnCreate
Activity
Media Controller events
a sample layout file
You can only change the layout file: