I have learn how to resize video playing on this Full screen videoview without stretching the video .
With gameowner
answer, it works. And it also force to keep aspect radio such that it will end up with black stripes in the sides.
I would like to have another optional. That is I do not want to have black stripes in the sides. I would like the video height is still remain in screen height. To keep aspect radio, the video width should greater than screen width. It doesn't matter that I cannot watch the "most left part" and "most right part" of video. I think I just need to change from:
if (videoProportion > screenProportion) {
lp.width = screenWidth;
lp.height = (int) ((float) screenWidth / videoProportion);
} else {
lp.width = (int) (videoProportion * (float) screenHeight);
lp.height = screenHeight;
}
to
if (videoProportion < screenProportion) {
lp.width = screenWidth;
lp.height = (int) ((float) screenWidth / videoProportion);
} else {
lp.width = (int) (videoProportion * (float) screenHeight);
lp.height = screenHeight;
}
would be ok but I didn't.
Once the surfaceView
size is larger than the screen. This just show black screen but keep aduio playing.
I also try to take surfaceview holder fixed size into account:
surfaceViewFrame.getHolder().setFixedSize(lp.width, lp.height);
but it does not solve the problem. Is it possible to play video which size is greater than screen?
Edit: OK. I have realized that the term of my question. I would like to zoom-in my video in aspect radio and but in fullscreen. Also known as crop video to fullscreen.
I tried to use TextureView
inside a FrameLayout
(required) container:
Playing video on TextureView
I have Android 4.0 devices that work fine in this workaround but I am not sure it really work on other 4.0 devices. Also TextureView
is Android 4.0 or above only. I would be grateful if there is workaround for Android 2.x.