androidscaleexoplayer2.x

ExoPlayer video not cropping and fit


I use ExoPlayer library for loading videos from my server and I want to scale and crop the videos to keep their aspect ratio. The videos playing fine and everything are fine even when I change the volume of the video. I tried to use the setVideoScalingMode function on the SimpleExoPlayer and passed:

C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING

Nothing happens and I also tried to change the resize attribute to fill/fit. Still no scaling and cropping.


Solution

  • After a lot of research all over the internet and after a lot of time debugging the exoplayer library code in order to understand why the scaling doesn't work, I found another option for the "resizeMode" attribute via code instead of the xml option which is RESIZE_MODE_ZOOM and it cropped the video to maintain the ratio. Hope it will help someone who will encounter the problem.