I am using Exoplayer to load videos from the Internet.
When the videos is loaded and starts to display inside the container, the video automatically stretches while the flag MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT
is set on the video renderer.
this._videoRenderer = new MediaCodecVideoTrackRenderer(this._context, source, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT);
Layout:
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/selfie_slider_slide_thumbnail"
android:layout_gravity="center|center_vertical"
android:visibility="gone" />
<SurfaceView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/selfie_slider_slide_video"
android:layout_gravity="center|center_vertical" />
</LinearLayout>
The image is correctly displayed, but not the video. Here are two examples to correctly illustrate the problem:
This is the video once it is loaded. You can see that it is stretched (don't pay attention to the black lines, this is a bad cropping)
I guess I could be resizing the container according to the thumbnail size, but that would mean that I would need to resize the container every time the video changes, so I'm trying to find a better way to do that. If anyone has a guess, I'm taking it!