How can I scale video in ExoPlayer-V2 - Play video in full screen

I play video from my server on Exoplayer , but it stretches the video when resizing and the inability to maintain the aspect ratio of the video.

I want to make the scale type CENTER_CROP , as in TextureSurface

I tried the following example

Exoplayer Demo

My conclusion (Img 1) and the expected result (Img 2)

enter image description here

My layout code

  <com.google.android.exoplayer2.ui.SimpleExoPlayerView android:id="@+id/player_view" android:layout_width="match_parent" android:layout_height="match_parent" app:resize_mode="fill" /> 

Using this line app:resize_mode="fill" it fills the video on the screen, but is stretched vertically. So how can I solve this.

0
source share
1 answer

The next line helped me solve this problem.

 exoVideoView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL); exoPlayer.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING); 
+1
source

Source: https://habr.com/ru/post/979444/


All Articles