Fix setting of resizeMode and repeat when changing source
This commit is contained in:
parent
ab802303f3
commit
9723f8849f
14
RCTVideo.m
14
RCTVideo.m
@ -39,6 +39,8 @@ static NSString *const statusKeyPath = @"status";
|
||||
float _rate;
|
||||
BOOL _muted;
|
||||
BOOL _paused;
|
||||
BOOL _repeat;
|
||||
NSString * _resizeMode;
|
||||
}
|
||||
|
||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
|
||||
@ -48,6 +50,8 @@ static NSString *const statusKeyPath = @"status";
|
||||
_rate = 1.0;
|
||||
_volume = 1.0;
|
||||
|
||||
_resizeMode = @"AVLayerVideoGravityResizeAspectFill";
|
||||
|
||||
_pendingSeek = false;
|
||||
_pendingSeekTime = 0.0f;
|
||||
_lastSeekTime = 0.0f;
|
||||
@ -156,6 +160,8 @@ static NSString *const statusKeyPath = @"status";
|
||||
_playerLayer.frame = self.bounds;
|
||||
_playerLayer.needsDisplayOnBoundsChange = YES;
|
||||
|
||||
[self applyModifiers];
|
||||
|
||||
[self.layer addSublayer:_playerLayer];
|
||||
self.layer.needsDisplayOnBoundsChange = YES;
|
||||
|
||||
@ -216,7 +222,7 @@ static NSString *const statusKeyPath = @"status";
|
||||
} else if(_playerItem.status == AVPlayerItemStatusFailed) {
|
||||
[_eventDispatcher sendInputEventWithName:RNVideoEventLoadingError body:@{
|
||||
@"error": @{
|
||||
@"code": [NSNumber numberWithInt:_playerItem.error.code],
|
||||
@"code": [NSNumber numberWithInt: (int)_playerItem.error.code],
|
||||
@"domain": _playerItem.error.domain
|
||||
},
|
||||
@"target": self.reactTag
|
||||
@ -248,6 +254,7 @@ static NSString *const statusKeyPath = @"status";
|
||||
|
||||
- (void)setResizeMode:(NSString*)mode
|
||||
{
|
||||
_resizeMode = mode;
|
||||
_playerLayer.videoGravity = mode;
|
||||
}
|
||||
|
||||
@ -327,6 +334,9 @@ static NSString *const statusKeyPath = @"status";
|
||||
}
|
||||
|
||||
[_player setRate:_rate];
|
||||
|
||||
[self setResizeMode:_resizeMode];
|
||||
[self setRepeat:_repeat];
|
||||
[self setPaused:_paused];
|
||||
}
|
||||
|
||||
@ -344,6 +354,8 @@ static NSString *const statusKeyPath = @"status";
|
||||
}
|
||||
|
||||
- (void)setRepeat:(BOOL)repeat {
|
||||
_repeat = repeat;
|
||||
|
||||
if (repeat) {
|
||||
[self setRepeatEnabled];
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user