Skip to content

Commit

Permalink
Fix exoplayer aspect ratio update on source changes (TheWidlarzGroup#…
Browse files Browse the repository at this point in the history
…2053)

* Fix exoplayer aspect ratio update on source changes

* Update CHANGELOG.md
  • Loading branch information
jefersondaniel authored and brianpmarks committed May 28, 2021
1 parent 20f4c26 commit 3181b70
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Added preventsDisplaySleepDuringVideoPlayback (#2019)
- Reverted the JS fullscreening for Android. [#2013](https://github.com/react-native-community/react-native-video/pull/2013)
- Set iOS request headers without needing to edit RCTVideo.m. [#2014](https://github.com/react-native-community/react-native-video/pull/2014)
- Fix exoplayer aspect ratio update on source changes [#2053](https://github.com/react-native-community/react-native-video/pull/2053)

### Version 5.1.0-alpha5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public float getAspectRatio() {
return videoAspectRatio;
}

public void invalidateAspectRatio() {
videoAspectRatio = 0;
}

/**
* Sets the resize mode which can be of value {@link ResizeMode.Mode}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ private void updateForCurrentTrackSelections() {
shutterView.setVisibility(VISIBLE);
}

public void invalidateAspectRatio() {
// Resetting aspect ratio will force layout refresh on next video size changed
layout.invalidateAspectRatio();
}

private final class ComponentListener implements SimpleExoPlayer.VideoListener,
TextOutput, ExoPlayer.EventListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ public void run() {
player.setPlaybackParameters(params);
}
if (playerNeedsSource && srcUri != null) {
exoPlayerView.invalidateAspectRatio();

ArrayList<MediaSource> mediaSourceList = buildTextSources();
MediaSource videoSource = buildMediaSource(srcUri, extension);
MediaSource mediaSource;
Expand Down

0 comments on commit 3181b70

Please sign in to comment.