From 7b1e1293f67c0e25e0763d08d830fcf192bb713c Mon Sep 17 00:00:00 2001 From: Olivier Bouillet <62574056+freeboub@users.noreply.github.com> Date: Fri, 17 May 2024 14:47:03 +0200 Subject: [PATCH] fix(android): avoid blinking on video track change (#3782) * perf: ensure we do not provide callback to native if no callback provided from app * chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size * chore: improve issue template * fix(android): avoid video view flickering at playback startup * 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) {