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 to
MyVideoView extends VideoView
https://stackoverflow.com/questions/4434027/android-videoview-orientation-change-with-buffered-video/4452597#4452597
as for showing MediaController over VidowView
Declare
private MediaController controller = null;
OnCreate
controller = new MediaController(this);
controller.setMediaPlayer(mcEvents);
controller.setAnchorView(findViewById(R.id.wrapper));
Activity
@Override
public boolean onTouchEvent(MotionEvent event) {
//the MediaController will hide after 3 seconds - tap the screen to make it appear again
controller.show();
return false;
}
Media Controller events
private MediaController.MediaPlayerControl mcEvents = new MediaController.MediaPlayerControl() {
public void start() {
player.start();
}
public void seekTo(int pos) {
player.seekTo(pos);
}
public void pause() {
player.pause();
}
public boolean isPlaying() {
return player.isPlaying();
}
public int getDuration() {
return player.getDuration();
}
public int getCurrentPosition() {
return player.getCurrentPosition();
}
public int getBufferPercentage() {
return pBuffer;
}
public boolean canSeekForward() {
return true;
}
public boolean canSeekBackward() {
return true;
}
public boolean canPause() {
return true;
}
};
a sample layout file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/wrapper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.my.views.MyViedoView
android:id="@+id/player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</FrameLayout>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…