How can I scale video in ExoPlayer-V2 - Play Video In Full Screen

前端 未结 4 451
面向向阳花
面向向阳花 2020-12-13 14:51

I am playing video from URL on Exoplayer, it stretching the video on resizing/on using resize_mode as I have mentioned in layout file

相关标签:
4条回答
  • 2020-12-13 15:22

    To maintain center crop in exo player below code worked for me:

    Java code:

    playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM);
    

    or you can use from xml:

    <com.google.android.exoplayer2.ui.PlayerView
        android:id="@+id/playerView"
        android:layout_width="match_parent"
        app:resize_mode="zoom"
        android:layout_height="match_parent" />
    
    0 讨论(0)
  • 2020-12-13 15:24

    My issue was solved using below lines:

    playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
    exoPlayer.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
    
    0 讨论(0)
  • 2020-12-13 15:31

    Following two lines helped me to play video in full-screen mode.

    Using app:resize_mode in layout file this somehow help but it stretches the video as mentioned in the question picture, so you can solve by adding these two lines in your code.

    exoVideoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
    exoPlayer.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
    

    Bellow line will ensure that aspect ratio is correctly maintained even for 4:3 videos.

    playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);. 
    
    0 讨论(0)
  • 2020-12-13 15:35

    Following are the Resize Mode options to play around with

    app:resize_mode="fixed_width"
    app:resize_mode="fixed_height"
    app:resize_mode="fill"
    app:resize_mode="fit"
    app:resize_mode="zoom"
    

    You can try each one to see its affect on your container.

    0 讨论(0)
提交回复
热议问题