Does Android support scaling Video?

Viewed 33946

Using a VideoView is it possible to set a scale factor for Android? By Default the video view resizes itself to fit the encoded resolution of the Video. Can I force Android to render a video into a smaller or larger rect?

7 Answers

(I know it's very old question, but there is another way to control dimensions, which isn't described here, maybe someone will find it helpful.)

Declare your own MyVideoView class in your layout and write your own onMeasure() method. Here is how to run video stretched to original View's dimensions:


public class MyVideoView extends VideoView {
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  int width = getDefaultSize(0, widthMeasureSpec);
  int height = getDefaultSize(0, heightMeasureSpec);

  setMeasuredDimension(width, height);
 }
}

By Default the video view resizes itself to fit the encoded resolution of the Video.

VideoView (or the SurfaceView for use with MediaPlayer) will be the size you tell it to be in your layout. Within that space, the video will play back as large as possible while maintaining the aspect ratio.

Can I force Android to render a video into a smaller or larger rect?

Yes: make your VideoView be the size you want, and Android will scale to fit the size of the VideoView.

Related