Commit 97f3e132 by bachinger Committed by Tofunmi Adigun-Hameed

Keep aspect ratio of `PlayerView` when IDLE

When the video renderer is disabled, the video size is set to 0/0
and sent to listeners. The `PlayerView` potentially still has the last frame
displayed when the player is stopped or an error occurs. This may have the
effect that the frame is displayed distorted.

Not changing the aspect ratio when the video size arrives when the player is IDLE
avoids the problem. In the case when playback starts again and the renderes is
enabled, another video size is sent to the listener.

#minor-release

PiperOrigin-RevId: 534860889
(cherry picked from commit 3e3aaf8816aa4a425343ac4aaf2299cd6e9f8085)
parent 5dfb011e
......@@ -1564,6 +1564,10 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
@Override
public void onVideoSizeChanged(VideoSize videoSize) {
if (videoSize.equals(VideoSize.UNKNOWN)
&& (player == null || player.getPlaybackState() == Player.STATE_IDLE)) {
return;
}
updateAspectRatio();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment