From ddf3964745d5dc8fcabf9d7efa65b8c355306843 Mon Sep 17 00:00:00 2001 From: Olivier Bouillet Date: Thu, 16 May 2024 10:55:45 +0200 Subject: [PATCH] fix(android): avoid ghost resizing when video track change --- .../main/java/com/brentvatne/exoplayer/ExoPlayerView.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java index 9b7904c5c3..dc5b184c11 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java @@ -279,7 +279,12 @@ public void onCues(List cues) { @Override public void onVideoSizeChanged(VideoSize videoSize) { boolean isInitialRatio = layout.getAspectRatio() == 0; - layout.setAspectRatio(videoSize.height == 0 ? 1 : (videoSize.width * videoSize.pixelWidthHeightRatio) / videoSize.height); + if (videoSize.height == 0 || videoSize.width == 0) { + // When changing video track we receive an ghost state with height / width = 0 + // No need to resize the view in that case + return; + } + layout.setAspectRatio((videoSize.width * videoSize.pixelWidthHeightRatio) / videoSize.height); // React native workaround for measuring and layout on initial load. if (isInitialRatio) {