From a435efe3d0aeed3267165487c2d708b7d8fe0a77 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Wed, 24 Jun 2015 21:26:36 -0700 Subject: [PATCH] Various fixes - Call super in removeFromSuperview - setRate has to come at the end of modifiers - Switch to requireNativeComponent --- RCTVideo.m | 6 +++--- Video.ios.js | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/RCTVideo.m b/RCTVideo.m index 3182c49f..47aa2707 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -325,7 +325,6 @@ static NSString *const statusKeyPath = @"status"; - (void)applyModifiers { - /* volume must be set to 0 if muted is YES, or the video freezes playback */ if (_muted) { [_player setVolume:0]; [_player setMuted:YES]; @@ -334,11 +333,10 @@ static NSString *const statusKeyPath = @"status"; [_player setMuted:NO]; } - [_player setRate:_rate]; - [self setResizeMode:_resizeMode]; [self setRepeat:_repeat]; [self setPaused:_paused]; + [_player setRate:_rate]; } - (void)setRepeat:(BOOL)repeat { @@ -382,6 +380,8 @@ static NSString *const statusKeyPath = @"status"; _eventDispatcher = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [super removeFromSuperview]; } @end diff --git a/Video.ios.js b/Video.ios.js index 4e59385f..6266a73a 100644 --- a/Video.ios.js +++ b/Video.ios.js @@ -1,8 +1,8 @@ var React = require('react-native'); -var NativeModules = require('NativeModules'); +var { requireNativeComponent, } = React; var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); +var NativeModules = require('NativeModules'); var StyleSheet = require('StyleSheet'); -var createReactIOSNativeComponentClass = require('createReactNativeComponentClass'); var PropTypes = require('ReactPropTypes'); var StyleSheetPropType = require('StyleSheetPropType'); var VideoResizeMode = require('./VideoResizeMode'); @@ -14,6 +14,11 @@ var deepDiffer = require('deepDiffer'); var Video = React.createClass({ propTypes: { + /* Native only */ + src: PropTypes.object, + seek: PropTypes.number, + + /* Wrapper component */ style: StyleSheetPropType(VideoStylePropTypes), source: PropTypes.object, resizeMode: PropTypes.string, @@ -103,12 +108,7 @@ var Video = React.createClass({ }, }); -var RCTVideo = createReactIOSNativeComponentClass({ - validAttributes: merge(ReactNativeViewAttributes.UIView, - {src: {diff: deepDiffer}, resizeMode: true, repeat: true, - seek: true, paused: true, muted: true, volume: true, rate: true}), - uiViewClassName: 'RCTVideo', -}); +var RCTVideo = requireNativeComponent('RCTVideo', Video); var styles = StyleSheet.create({ base: {