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
This commit is contained in:
bachinger 2023-05-24 16:59:34 +01:00 committed by tonihei
parent 749c64c74f
commit 6469fffd8f

View File

@ -1602,6 +1602,10 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
@Override @Override
public void onVideoSizeChanged(VideoSize videoSize) { public void onVideoSizeChanged(VideoSize videoSize) {
if (videoSize.equals(VideoSize.UNKNOWN)
&& (player == null || player.getPlaybackState() == Player.STATE_IDLE)) {
return;
}
updateAspectRatio(); updateAspectRatio();
} }