How to show video in full screen without stretching? - android

I have used video as Full Screen background in the frame layout. But video running in the background looks stretched.If i use aspect ratio, the video layout may be shrinked depends on the screen width / screen height. how to rectify this?

Related

How to overlap a SurfaceView beyond the display area in Kotlin?

I have this school project where I have to adjust a video content
depending on the aspect ratio of the display area based on the set Screen Format.
I'm already done with the following Screen Formats:
Stretch-to-Fit
Letterbox/Pillarbox
But I just can't seem to nail the Crop format.
BACKGROUND:
Cropping happens when the display area aspect ratio is smaller than that of the video content
For example:
The display area is in (4:3) aspect ratio and video content is at (16:9) aspect ratio,
What is expected is:
Crop Format
The height of the video content will match that of the display area but doing so will also
increase the width of the video content. But the Crop format will just crop both sides of the
video content to match the display area.
NOTE:
I don't have access to the MediaPlayer class since I just pass the SurfaceView to another
component so the video content will be drawn.
It's been a few weeks now and I'm at my wits end that's why I decided to post here
for help.
Thank you
WHAT I ALREADY TRIED:
I already tried Scaling the SurfaceView using the setScaleX(2.0f) method.
But it doesn't seem to go beyond the display area.
I also tried setting the LayoutParams width to twice the value.
But it doesn't go beyond the display area too.

ExoPlayer2 Scaling

I have an Activity that contains a FrameLayout where ExoPlayer takes place.
This activity support both orientations and video aspect ratio should be preserved.
According to ExoPlayer docs, for the setResizeMode we can have one of the following:
RESIZE_MODE_FIT,
RESIZE_MODE_FIXED_WIDTH,
RESIZE_MODE_FIXED_HEIGHT,
RESIZE_MODE_FILL,
RESIZE_MODE_ZOOM
In my case, since I don't know the video size nor the device orientation, I can have two scenarios:
Video is larger than my Viewport, so I would like to have RESIZE_MODE_FIT to scale it down
Video is smaller than my Viewport, so I would like to have RESIZE_MODE_ZOOM to scale it up.
But in the end I could not find a way to achieve this behavior.
If I set RESIZE_MODE_FIT, small videos does not fill my Viewport.
If I set RESIZE_MODE_ZOOM, large videos overflow the Viewport.
Thanks.

How to make a video full screen using an Exoplayer without stretching it

I'm using an ExoPlayer to show videos, currently I just maintain the aspect ratio as default but this isn't ideal as I want the videos full screen.
for (Listener listener : mListeners) {
listener.onVideoSizeChanged(width, height, pixelWidthHeightRatio);
}
I've tried setting the video to take the entire width of the screen however this just stretches and distorts the video. Any idea how to scale the video up while maintain its height:width ratio?
try adding this lines
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); //will hide the status bar
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); //will rotate the screen

Android SurfaceView resize to fit screen 16:9

Hello! Is there a good way of having a 16:9 SurfaceView, and then resize it bigger until it touches a screen edge? (so the SurfaceView is at its biggest size and still 16:9 and not outside the screen)
I have heard it is called letterbox, but havn't found any tutorial about it.
Thanks
There are two relevant sizes, the size of the Surface and the size of the View.
The size of the Surface is determined by the size of the video being rendered to it. You can't change this. A 720p video will set the size to 1280x720.
The size of the View is determined by the layout code. This can be set from within your app.
The system compositor (SurfaceFlinger) will scale the contents of the Surface so they fit in the View. To avoid distortion, you want to maintain the same aspect ratio. You do this with a custom FrameLayout.
For an example, see how AspectFrameLayout is used in Grafika's video players, e.g. this chunk of code.

How to scale video on a SurfaceView larger than the window on Android?

Android 2.2 (on a media player boxtop) with a display of 1280x720.
My video is 480px high, 720px wide; standard definition.
I know that if change the layouts of a SurfaceView, the video is scaled to fit whichever is smallest to maintain aspect ratio.
This is great, except I can only scale up to the height of the screen. This is a problem as there is are black bars being broadcast on the top/bottom of the video.
See here:
http://i.imgur.com/dsiLw.jpg
I would need to make my SurfaceView (and the window) larger than the screen.
I know about FLAG_LAYOUT_NO_LIMITS, on WindowManager:
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_LAYOUT_NO_LIMITS
It is supposed to allow my window to expand out past the screen... but I can't seem to get this working. It always seems to resize it to 1280x720px no matter what I do.
If you could help me get this so I can expand my surfaceview video so it looks full screen (clipping the tops video), I will be extremely grateful.
:)

Categories

Resources