Skip to content

Crop mode (VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING) not applied on first loop #2344

@aneesh1122

Description

@aneesh1122

Version

Media3 main branch

More version details

No response

Devices that reproduce the issue

Mi 11x Android 12

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

  1. Set up an ExoPlayer instance with videoScalingMode = VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING.

  2. Set repeatMode = Player.REPEAT_MODE_ONE so the video loops.

  3. Assign the player to a PlayerView with resizeMode = RESIZE_MODE_FILL.

  4. Provide a standard MP4 video that is vertical (e.g., 9:16), but does not match the device’s screen aspect ratio.

  5. Observe playback:

  6. On the first loop, the video appears stretched or not cropped correctly.

  7. On the second loop and onwards, the video suddenly displays properly (cropped as expected).

Note: My player supports both HLS and MP4, but this issue is being seen specifically with an MP4 file.

Expected result

The video should be cropped correctly (zoomed and centered) to fill the PlayerView from the very first loop, honoring both VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING and RESIZE_MODE_FILL.

There should be no difference in video display between the first loop and subsequent loops.

Actual result

On the first loop, the video appears stretched, misaligned, or not cropped properly — as if the scaling or aspect ratio hasn’t been applied yet.

From the second loop onwards, the video suddenly displays correctly, cropped and zoomed as expected.

Example setup:

Inside a Jetpack Compose app, create an ExoPlayer instance using:
exoPlayer.videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING

Set repeat mode:
exoPlayer.repeatMode = Player.REPEAT_MODE_ONE

Assign the player to a PlayerView inside an AndroidView, and set:
playerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FILL

Use an .mp4 source video that is vertical (e.g., 9:16), but does not match the device’s screen aspect ratio, such as 9:20.

Media

Not applicable

Bug Report

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions