Support for HLS maximum bit rate adaptive streaming
This commit is contained in:
parent
d8a19e66c3
commit
11db343987
@ -583,6 +583,9 @@ Sets the media source. You can pass an asset loaded via require or an object wit
|
|||||||
|
|
||||||
The docs for this prop are incomplete and will be updated as each option is investigated and tested.
|
The docs for this prop are incomplete and will be updated as each option is investigated and tested.
|
||||||
|
|
||||||
|
#### maximumBitRate
|
||||||
|
Sets the maximum bit rate for HLS media sources. If an HLS m3u8 manifest describes multiple streams, the maximum bit rate determines the video stream selected
|
||||||
|
|
||||||
##### Asset loaded via require
|
##### Asset loaded via require
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
1
Video.js
1
Video.js
@ -330,6 +330,7 @@ Video.propTypes = {
|
|||||||
// Opaque type returned by require('./video.mp4')
|
// Opaque type returned by require('./video.mp4')
|
||||||
PropTypes.number
|
PropTypes.number
|
||||||
]),
|
]),
|
||||||
|
maximumBitRate: PropTypes.number,
|
||||||
resizeMode: PropTypes.string,
|
resizeMode: PropTypes.string,
|
||||||
poster: PropTypes.string,
|
poster: PropTypes.string,
|
||||||
posterResizeMode: Image.propTypes.resizeMode,
|
posterResizeMode: Image.propTypes.resizeMode,
|
||||||
|
@ -110,6 +110,7 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
private boolean isBuffering;
|
private boolean isBuffering;
|
||||||
private float rate = 1f;
|
private float rate = 1f;
|
||||||
private float audioVolume = 1f;
|
private float audioVolume = 1f;
|
||||||
|
private int maximumBitRate = 0;
|
||||||
|
|
||||||
private int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS;
|
private int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS;
|
||||||
private int maxBufferMs = DefaultLoadControl.DEFAULT_MAX_BUFFER_MS;
|
private int maxBufferMs = DefaultLoadControl.DEFAULT_MAX_BUFFER_MS;
|
||||||
@ -244,6 +245,9 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
|
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
|
||||||
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
|
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
|
||||||
|
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||||
|
.setMaxVideoBitrate(maximumBitRate));
|
||||||
|
|
||||||
DefaultAllocator allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE);
|
DefaultAllocator allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE);
|
||||||
DefaultLoadControl defaultLoadControl = new DefaultLoadControl(allocator, minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs, -1, true);
|
DefaultLoadControl defaultLoadControl = new DefaultLoadControl(allocator, minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs, -1, true);
|
||||||
player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, defaultLoadControl);
|
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) {
|
public void setPlayInBackground(boolean playInBackground) {
|
||||||
this.playInBackground = playInBackground;
|
this.playInBackground = playInBackground;
|
||||||
|
@ -47,6 +47,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
private static final String PROP_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval";
|
private static final String PROP_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval";
|
||||||
private static final String PROP_SEEK = "seek";
|
private static final String PROP_SEEK = "seek";
|
||||||
private static final String PROP_RATE = "rate";
|
private static final String PROP_RATE = "rate";
|
||||||
|
private static final String PROP_MAXIMUM_BIT_RATE = "maximumBitRate";
|
||||||
private static final String PROP_PLAY_IN_BACKGROUND = "playInBackground";
|
private static final String PROP_PLAY_IN_BACKGROUND = "playInBackground";
|
||||||
private static final String PROP_DISABLE_FOCUS = "disableFocus";
|
private static final String PROP_DISABLE_FOCUS = "disableFocus";
|
||||||
private static final String PROP_FULLSCREEN = "fullscreen";
|
private static final String PROP_FULLSCREEN = "fullscreen";
|
||||||
@ -200,6 +201,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
videoView.setRateModifier(rate);
|
videoView.setRateModifier(rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactProp(name = PROP_MAXIMUM_BIT_RATE)
|
||||||
|
public void setMaximumBitRate(final ReactExoplayerView videoView, final int maximumBitRate) {
|
||||||
|
videoView.setMaximumBitRateModifier(maximumBitRate);
|
||||||
|
}
|
||||||
|
|
||||||
@ReactProp(name = PROP_PLAY_IN_BACKGROUND, defaultBoolean = false)
|
@ReactProp(name = PROP_PLAY_IN_BACKGROUND, defaultBoolean = false)
|
||||||
public void setPlayInBackground(final ReactExoplayerView videoView, final boolean playInBackground) {
|
public void setPlayInBackground(final ReactExoplayerView videoView, final boolean playInBackground) {
|
||||||
videoView.setPlayInBackground(playInBackground);
|
videoView.setPlayInBackground(playInBackground);
|
||||||
|
@ -51,6 +51,8 @@ static int const RCTVideoUnset = -1;
|
|||||||
/* Keep track of any modifiers, need to be applied after each play */
|
/* Keep track of any modifiers, need to be applied after each play */
|
||||||
float _volume;
|
float _volume;
|
||||||
float _rate;
|
float _rate;
|
||||||
|
float _maximumBitRate;
|
||||||
|
|
||||||
BOOL _muted;
|
BOOL _muted;
|
||||||
BOOL _paused;
|
BOOL _paused;
|
||||||
BOOL _repeat;
|
BOOL _repeat;
|
||||||
@ -338,6 +340,8 @@ static int const RCTVideoUnset = -1;
|
|||||||
[self addPlayerItemObservers];
|
[self addPlayerItemObservers];
|
||||||
[self setFilter:_filterName];
|
[self setFilter:_filterName];
|
||||||
|
|
||||||
|
_playerItem.preferredPeakBitRate = _maximumBitRate;
|
||||||
|
|
||||||
[_player pause];
|
[_player pause];
|
||||||
[_playerViewController.view removeFromSuperview];
|
[_playerViewController.view removeFromSuperview];
|
||||||
_playerViewController = nil;
|
_playerViewController = nil;
|
||||||
@ -378,6 +382,11 @@ static int const RCTVideoUnset = -1;
|
|||||||
_videoLoadStarted = YES;
|
_videoLoadStarted = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setMaximumBitRate:(float) maximumBitRate {
|
||||||
|
_maximumBitRate = maximumBitRate;
|
||||||
|
[self applyModifiers];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSURL*) urlFilePath:(NSString*) filepath {
|
- (NSURL*) urlFilePath:(NSString*) filepath {
|
||||||
if ([filepath containsString:@"file://"]) {
|
if ([filepath containsString:@"file://"]) {
|
||||||
return [NSURL URLWithString:filepath];
|
return [NSURL URLWithString:filepath];
|
||||||
|
@ -19,6 +19,7 @@ RCT_EXPORT_MODULE();
|
|||||||
}
|
}
|
||||||
|
|
||||||
RCT_EXPORT_VIEW_PROPERTY(src, NSDictionary);
|
RCT_EXPORT_VIEW_PROPERTY(src, NSDictionary);
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(maximumBitRate, float);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString);
|
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL);
|
RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(allowsExternalPlayback, BOOL);
|
RCT_EXPORT_VIEW_PROPERTY(allowsExternalPlayback, BOOL);
|
||||||
|
Loading…
Reference in New Issue
Block a user