fix(android): ensure maxbitrate & selectedVideoTrack interact correctly (#4155)
This commit is contained in:
parent
1ef2b3a977
commit
7f6b500c82
@ -565,6 +565,11 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||
reLayout(playerControlView);
|
||||
}
|
||||
|
||||
/// returns true is adaptive bitrate shall be used
|
||||
public boolean isUsingVideoABR() {
|
||||
return videoTrackType == null || "auto".equals(videoTrackType);
|
||||
}
|
||||
|
||||
public void setDebug(boolean enableDebug) {
|
||||
this.enableDebug = enableDebug;
|
||||
refreshDebugState();
|
||||
@ -2041,16 +2046,21 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||
|
||||
TrackSelectionOverride selectionOverride = new TrackSelectionOverride(groups.get(groupIndex), tracks);
|
||||
|
||||
DefaultTrackSelector.Parameters selectionParameters = trackSelector.getParameters()
|
||||
DefaultTrackSelector.Parameters.Builder selectionParameters = trackSelector.getParameters()
|
||||
.buildUpon()
|
||||
.setExceedAudioConstraintsIfNecessary(true)
|
||||
.setExceedRendererCapabilitiesIfNecessary(true)
|
||||
.setExceedVideoConstraintsIfNecessary(true)
|
||||
.setRendererDisabled(rendererIndex, false)
|
||||
.clearOverridesOfType(selectionOverride.getType())
|
||||
.addOverride(selectionOverride)
|
||||
.build();
|
||||
trackSelector.setParameters(selectionParameters);
|
||||
.clearOverridesOfType(selectionOverride.getType());
|
||||
|
||||
if (trackType == C.TRACK_TYPE_VIDEO && isUsingVideoABR()) {
|
||||
selectionParameters.setMaxVideoBitrate(maxBitRate == 0 ? Integer.MAX_VALUE : maxBitRate);
|
||||
} else {
|
||||
selectionParameters.addOverride(selectionOverride);
|
||||
}
|
||||
|
||||
trackSelector.setParameters(selectionParameters.build());
|
||||
}
|
||||
|
||||
private boolean isFormatSupported(Format format) {
|
||||
@ -2181,7 +2191,8 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||
|
||||
public void setMaxBitRateModifier(int newMaxBitRate) {
|
||||
maxBitRate = newMaxBitRate;
|
||||
if (player != null) {
|
||||
if (player != null && isUsingVideoABR()) {
|
||||
// do not apply yet if not auto
|
||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||
.setMaxVideoBitrate(maxBitRate == 0 ? Integer.MAX_VALUE : maxBitRate));
|
||||
}
|
||||
|
@ -361,6 +361,9 @@ Sets the desired limit, in bits per second, of network bandwidth consumption whe
|
||||
|
||||
Default: 0. Don't limit the maxBitRate.
|
||||
|
||||
Note: This property can interact with selectedVideoTrack.
|
||||
To use `maxBitrate`, selectedVideoTrack shall be undefined or `{type: SelectedVideoTrackType.AUTO}`.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
|
Loading…
Reference in New Issue
Block a user