Search code examples
androidandroid-layoutlogicmedia-playerexoplayer

Forcing video to take up entire width of SImpleExoPlayerView


I'm having trouble forcing a video to be the entire width of a SimpleExoPlayerView. I've read through a couple stack overflow posts and have not been successful. The layout:

<FrameLayout
android:id="@+id/video_framelayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.google.android.exoplayer2.ui.SimpleExoPlayerView
    android:id="@+id/post_videoView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    />

</FrameLayout>

I also tried using the following java code:

            postVideoView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
            postVideoView.getPlayer().setVideoScalingMode(MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);

Solution

  • I had to manually reset the resize_mode:

    <com.google.android.exoplayer2.ui.AspectRatioFrameLayout
        android:id="@+id/video_framelayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <com.google.android.exoplayer2.ui.SimpleExoPlayerView
            android:id="@+id/post_videoView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:resize_mode="fixed_width"/>
    
    </com.google.android.exoplayer2.ui.AspectRatioFrameLayout>