Support for HLS maximum bit rate adaptive streaming

This commit is contained in:
Ash Mishra
2018-10-29 09:53:52 -07:00
parent d8a19e66c3
commit 11db343987
6 changed files with 34 additions and 0 deletions

View File

@@ -110,6 +110,7 @@ class ReactExoplayerView extends FrameLayout implements
private boolean isBuffering;
private float rate = 1f;
private float audioVolume = 1f;
private int maximumBitRate = 0;
private int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS;
private int maxBufferMs = DefaultLoadControl.DEFAULT_MAX_BUFFER_MS;
@@ -244,6 +245,9 @@ class ReactExoplayerView extends FrameLayout implements
if (player == null) {
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
trackSelector.setParameters(trackSelector.buildUponParameters()
.setMaxVideoBitrate(maximumBitRate));
DefaultAllocator allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE);
DefaultLoadControl defaultLoadControl = new DefaultLoadControl(allocator, minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs, -1, true);
player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, defaultLoadControl);
@@ -906,6 +910,16 @@ class ReactExoplayerView extends FrameLayout implements
}
}
public void setMaximumBitRateModifier(int newMaximumBitRate) {
if (newMaximumBitRate==0) newMaximumBitRate = Integer.MAX_VALUE;
maximumBitRate = newMaximumBitRate;
if (player != null) {
trackSelector.setParameters(trackSelector.buildUponParameters()
.setMaxVideoBitrate(maximumBitRate));
}
}
public void setPlayInBackground(boolean playInBackground) {
this.playInBackground = playInBackground;