RCTVideo.m formatting

This commit is contained in:
Nicolas Gonzalez 2018-12-13 21:37:17 -06:00
parent 67a963328a
commit ebb237dc60

View File

@ -52,6 +52,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 _maxBitRate;
BOOL _muted; BOOL _muted;
BOOL _paused; BOOL _paused;
BOOL _repeat; BOOL _repeat;
@ -340,6 +342,7 @@ static int const RCTVideoUnset = -1;
_playerItem = playerItem; _playerItem = playerItem;
[self addPlayerItemObservers]; [self addPlayerItemObservers];
[self setFilter:_filterName]; [self setFilter:_filterName];
[self setMaxBitRate:_maxBitRate];
[_player pause]; [_player pause];
[_playerViewController.view removeFromSuperview]; [_playerViewController.view removeFromSuperview];
@ -404,11 +407,14 @@ static int const RCTVideoUnset = -1;
- (void)playerItemPrepareText:(AVAsset *)asset assetOptions:(NSDictionary * __nullable)assetOptions withCallback:(void(^)(AVPlayerItem *))handler - (void)playerItemPrepareText:(AVAsset *)asset assetOptions:(NSDictionary * __nullable)assetOptions withCallback:(void(^)(AVPlayerItem *))handler
{ {
if (!_textTracks) { if (!_textTracks || _textTracks.count==0) {
handler([AVPlayerItem playerItemWithAsset:asset]); handler([AVPlayerItem playerItemWithAsset:asset]);
return; return;
} }
// AVPlayer can't airplay AVMutableCompositions
_allowsExternalPlayback = NO;
// sideload text tracks // sideload text tracks
AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init]; AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init];
@ -853,6 +859,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) {
@ -863,6 +875,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];
@ -1281,7 +1295,6 @@ static int const RCTVideoUnset = -1;
if (!asset) { if (!asset) {
return; return;
} }
// TODO: filters don't work for HLS, check & return
CIFilter *filter = [CIFilter filterWithName:filterName]; CIFilter *filter = [CIFilter filterWithName:filterName];
_playerItem.videoComposition = [AVVideoComposition _playerItem.videoComposition = [AVVideoComposition