renamed maximumBitRate to maxBitRate. Added applyModifiers support
This commit is contained in:
parent
12a482a8e3
commit
5ab8165c3d
2
Video.js
2
Video.js
@ -330,7 +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,
|
maxBitRate: PropTypes.number,
|
||||||
resizeMode: PropTypes.string,
|
resizeMode: PropTypes.string,
|
||||||
poster: PropTypes.string,
|
poster: PropTypes.string,
|
||||||
posterResizeMode: Image.propTypes.resizeMode,
|
posterResizeMode: Image.propTypes.resizeMode,
|
||||||
|
@ -110,7 +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 maxBitRate = 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;
|
||||||
@ -246,7 +246,7 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
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()
|
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||||
.setMaxVideoBitrate(maximumBitRate));
|
.setMaxVideoBitrate(maxBitRate));
|
||||||
|
|
||||||
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);
|
||||||
@ -910,13 +910,13 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaximumBitRateModifier(int newMaximumBitRate) {
|
public void setMaxBitRateModifier(int newMaxBitRate) {
|
||||||
if (newMaximumBitRate==0) newMaximumBitRate = Integer.MAX_VALUE;
|
if (newMaxBitRate==0) newMaxBitRate = Integer.MAX_VALUE;
|
||||||
maximumBitRate = newMaximumBitRate;
|
maxBitRate = newMaxBitRate;
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||||
.setMaxVideoBitrate(maximumBitRate));
|
.setMaxVideoBitrate(maxBitRate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +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_MAXIMUM_BIT_RATE = "maxBitRate";
|
||||||
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";
|
||||||
@ -202,8 +202,8 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ReactProp(name = PROP_MAXIMUM_BIT_RATE)
|
@ReactProp(name = PROP_MAXIMUM_BIT_RATE)
|
||||||
public void setMaximumBitRate(final ReactExoplayerView videoView, final int maximumBitRate) {
|
public void setMaxBitRate(final ReactExoplayerView videoView, final int maxBitRate) {
|
||||||
videoView.setMaximumBitRateModifier(maximumBitRate);
|
videoView.setMaxBitRateModifier(maxBitRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactProp(name = PROP_PLAY_IN_BACKGROUND, defaultBoolean = false)
|
@ReactProp(name = PROP_PLAY_IN_BACKGROUND, defaultBoolean = false)
|
||||||
|
@ -51,7 +51,7 @@ 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;
|
float _maxBitRate;
|
||||||
|
|
||||||
BOOL _muted;
|
BOOL _muted;
|
||||||
BOOL _paused;
|
BOOL _paused;
|
||||||
@ -339,8 +339,7 @@ static int const RCTVideoUnset = -1;
|
|||||||
_playerItem = playerItem;
|
_playerItem = playerItem;
|
||||||
[self addPlayerItemObservers];
|
[self addPlayerItemObservers];
|
||||||
[self setFilter:_filterName];
|
[self setFilter:_filterName];
|
||||||
|
[self setMaxBitRate:_maxBitRate];
|
||||||
_playerItem.preferredPeakBitRate = _maximumBitRate;
|
|
||||||
|
|
||||||
[_player pause];
|
[_player pause];
|
||||||
[_playerViewController.view removeFromSuperview];
|
[_playerViewController.view removeFromSuperview];
|
||||||
@ -382,11 +381,6 @@ 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];
|
||||||
@ -859,6 +853,12 @@ static int const RCTVideoUnset = -1;
|
|||||||
[self applyModifiers];
|
[self applyModifiers];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setMaxBitRate:(float) maxBitRate {
|
||||||
|
_maxBitRate = maxBitRate;
|
||||||
|
[self applyModifiers];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)applyModifiers
|
- (void)applyModifiers
|
||||||
{
|
{
|
||||||
if (_muted) {
|
if (_muted) {
|
||||||
@ -869,6 +869,8 @@ static int const RCTVideoUnset = -1;
|
|||||||
[_player setMuted:NO];
|
[_player setMuted:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_playerItem.preferredPeakBitRate = _maxBitRate;
|
||||||
|
|
||||||
[self setSelectedAudioTrack:_selectedAudioTrack];
|
[self setSelectedAudioTrack:_selectedAudioTrack];
|
||||||
[self setSelectedTextTrack:_selectedTextTrack];
|
[self setSelectedTextTrack:_selectedTextTrack];
|
||||||
[self setResizeMode:_resizeMode];
|
[self setResizeMode:_resizeMode];
|
||||||
|
@ -19,7 +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(maxBitRate, 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