Skip to content

Commit

Permalink
fix(android): avoid ghost resizing when video track change
Browse files Browse the repository at this point in the history
  • Loading branch information
freeboub committed May 16, 2024
1 parent 9ce1d95 commit ddf3964
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@ public void onCues(List<Cue> 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) {
Expand Down

0 comments on commit ddf3964

Please sign in to comment.