2

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.

4

2 回答 2

8

经过互联网上的大量研究人员并经过大量时间调试 exoplayer 库代码以了解缩放不起作用的原因。我通过代码找到了“resizeMode”属性的另一个选项,而不是“RESIZE_MODE_ZOOM”的xml选项,它裁剪了视频以保持比例。希望有人会遇到这个问题。

于 2018-01-08T12:20:39.767 回答
2

JavaKotlin

playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM);

XML

<com.google.android.exoplayer2.ui.PlayerView
    android:id="@+id/playerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:resize_mode="zoom"/>
于 2018-12-12T10:50:13.867 回答