Respect the pause property at all times

This commit is contained in:
Brent Vatne 2015-05-10 16:01:25 -07:00
parent d9ea831321
commit 9c2184bd19
4 changed files with 11 additions and 9 deletions

View File

@ -37,6 +37,7 @@ static NSString *const statusKeyPath = @"status";
float _volume; float _volume;
float _rate; float _rate;
BOOL _muted; BOOL _muted;
BOOL _paused;
} }
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher { - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher {
@ -158,7 +159,6 @@ static NSString *const statusKeyPath = @"status";
[self startProgressTimer]; [self startProgressTimer];
[self attachListeners]; [self attachListeners];
[_player play];
[self applyModifiers]; [self applyModifiers];
} else if(_playerItem.status == AVPlayerItemStatusFailed) { } else if(_playerItem.status == AVPlayerItemStatusFailed) {
[_eventDispatcher sendInputEventWithName:RNVideoEventLoadingError body:@{ [_eventDispatcher sendInputEventWithName:RNVideoEventLoadingError body:@{
@ -186,7 +186,6 @@ static NSString *const statusKeyPath = @"status";
- (void)playerItemDidReachEnd:(NSNotification *)notification { - (void)playerItemDidReachEnd:(NSNotification *)notification {
AVPlayerItem *item = [notification object]; AVPlayerItem *item = [notification object];
[item seekToTime:kCMTimeZero]; [item seekToTime:kCMTimeZero];
[_player play];
[self applyModifiers]; [self applyModifiers];
} }
@ -203,8 +202,9 @@ static NSString *const statusKeyPath = @"status";
} else { } else {
[self startProgressTimer]; [self startProgressTimer];
[_player play]; [_player play];
} }
_paused = paused;
} }
- (void)setSeek:(float)seekTime { - (void)setSeek:(float)seekTime {
@ -265,6 +265,7 @@ static NSString *const statusKeyPath = @"status";
} }
[_player setRate:_rate]; [_player setRate:_rate];
[self setPaused:_paused];
} }
- (void)setRepeatEnabled { - (void)setRepeatEnabled {

View File

@ -51,10 +51,12 @@ RCT_EXPORT_VIEW_PROPERTY(seek, float);
- (NSDictionary *)constantsToExport - (NSDictionary *)constantsToExport
{ {
return @{@"ScaleNone": AVLayerVideoGravityResizeAspect, return @{
@"ScaleToFill": AVLayerVideoGravityResize, @"ScaleNone": AVLayerVideoGravityResizeAspect,
@"ScaleAspectFit": AVLayerVideoGravityResizeAspect, @"ScaleToFill": AVLayerVideoGravityResize,
@"ScaleAspectFill": AVLayerVideoGravityResizeAspectFill}; @"ScaleAspectFit": AVLayerVideoGravityResizeAspect,
@"ScaleAspectFill": AVLayerVideoGravityResizeAspectFill
};
} }
@end @end

View File

@ -14,7 +14,6 @@ var deepDiffer = require('deepDiffer');
var Video = React.createClass({ var Video = React.createClass({
propTypes: { propTypes: {
// should probably be a shape
source: PropTypes.object, source: PropTypes.object,
style: StyleSheetPropType(VideoStylePropTypes), style: StyleSheetPropType(VideoStylePropTypes),
source: PropTypes.object, source: PropTypes.object,

View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-video", "name": "react-native-video",
"version": "0.3.2", "version": "0.3.3",
"description": "A <Video /> element for react-native", "description": "A <Video /> element for react-native",
"main": "Video.ios.js", "main": "Video.ios.js",
"author": "Brent Vatne <brentvatne@gmail.com> (https://github.com/brentvatne)", "author": "Brent Vatne <brentvatne@gmail.com> (https://github.com/brentvatne)",