renamed maximumBitRate to maxBitRate. Added applyModifiers support

This commit is contained in:
Ash Mishra 2018-11-26 14:50:31 -08:00
parent 12a482a8e3
commit 5ab8165c3d
5 changed files with 22 additions and 20 deletions

View File

@ -330,7 +330,7 @@ Video.propTypes = {
// Opaque type returned by require('./video.mp4')
PropTypes.number
]),
maximumBitRate: PropTypes.number,
maxBitRate: PropTypes.number,
resizeMode: PropTypes.string,
poster: PropTypes.string,
posterResizeMode: Image.propTypes.resizeMode,

View File

@ -110,7 +110,7 @@ class ReactExoplayerView extends FrameLayout implements
private boolean isBuffering;
private float rate = 1f;
private float audioVolume = 1f;
private int maximumBitRate = 0;
private int maxBitRate = 0;
private int minBufferMs = DefaultLoadControl.DEFAULT_MIN_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);
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
trackSelector.setParameters(trackSelector.buildUponParameters()
.setMaxVideoBitrate(maximumBitRate));
.setMaxVideoBitrate(maxBitRate));
DefaultAllocator allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE);
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) {
if (newMaximumBitRate==0) newMaximumBitRate = Integer.MAX_VALUE;
maximumBitRate = newMaximumBitRate;
public void setMaxBitRateModifier(int newMaxBitRate) {
if (newMaxBitRate==0) newMaxBitRate = Integer.MAX_VALUE;
maxBitRate = newMaxBitRate;
if (player != null) {
trackSelector.setParameters(trackSelector.buildUponParameters()
.setMaxVideoBitrate(maximumBitRate));
.setMaxVideoBitrate(maxBitRate));
}
}

View File

@ -47,7 +47,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
private static final String PROP_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval";
private static final String PROP_SEEK = "seek";
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_DISABLE_FOCUS = "disableFocus";
private static final String PROP_FULLSCREEN = "fullscreen";
@ -202,8 +202,8 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
}
@ReactProp(name = PROP_MAXIMUM_BIT_RATE)
public void setMaximumBitRate(final ReactExoplayerView videoView, final int maximumBitRate) {
videoView.setMaximumBitRateModifier(maximumBitRate);
public void setMaxBitRate(final ReactExoplayerView videoView, final int maxBitRate) {
videoView.setMaxBitRateModifier(maxBitRate);
}
@ReactProp(name = PROP_PLAY_IN_BACKGROUND, defaultBoolean = false)

View File

@ -51,7 +51,7 @@ static int const RCTVideoUnset = -1;
/* Keep track of any modifiers, need to be applied after each play */
float _volume;
float _rate;
float _maximumBitRate;
float _maxBitRate;
BOOL _muted;
BOOL _paused;
@ -339,8 +339,7 @@ static int const RCTVideoUnset = -1;
_playerItem = playerItem;
[self addPlayerItemObservers];
[self setFilter:_filterName];
_playerItem.preferredPeakBitRate = _maximumBitRate;
[self setMaxBitRate:_maxBitRate];
[_player pause];
[_playerViewController.view removeFromSuperview];
@ -382,11 +381,6 @@ static int const RCTVideoUnset = -1;
_videoLoadStarted = YES;
}
- (void)setMaximumBitRate:(float) maximumBitRate {
_maximumBitRate = maximumBitRate;
[self applyModifiers];
}
- (NSURL*) urlFilePath:(NSString*) filepath {
if ([filepath containsString:@"file://"]) {
return [NSURL URLWithString:filepath];
@ -859,6 +853,12 @@ static int const RCTVideoUnset = -1;
[self applyModifiers];
}
- (void)setMaxBitRate:(float) maxBitRate {
_maxBitRate = maxBitRate;
[self applyModifiers];
}
- (void)applyModifiers
{
if (_muted) {
@ -869,6 +869,8 @@ static int const RCTVideoUnset = -1;
[_player setMuted:NO];
}
_playerItem.preferredPeakBitRate = _maxBitRate;
[self setSelectedAudioTrack:_selectedAudioTrack];
[self setSelectedTextTrack:_selectedTextTrack];
[self setResizeMode:_resizeMode];

View File

@ -19,7 +19,7 @@ RCT_EXPORT_MODULE();
}
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(repeat, BOOL);
RCT_EXPORT_VIEW_PROPERTY(allowsExternalPlayback, BOOL);