diff --git a/RCTVideo.m b/RCTVideo.m index cc5101c4..12024132 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -34,6 +34,15 @@ _playerLayer.videoGravity = mode; } +- (void)setPause:(BOOL)wantsToPause +{ + if (wantsToPause) { + [_player pause]; + } else { + [_player play]; + } +} + - (void)playerItemDidReachEnd:(NSNotification *)notification { AVPlayerItem *item = [notification object]; diff --git a/RCTVideoManager.m b/RCTVideoManager.m index 49e08239..ba67946c 100644 --- a/RCTVideoManager.m +++ b/RCTVideoManager.m @@ -15,6 +15,7 @@ RCT_EXPORT_VIEW_PROPERTY(src, NSString); RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString); RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL); +RCT_EXPORT_VIEW_PROPERTY(pause, BOOL); - (NSDictionary *)constantsToExport { diff --git a/Video.ios.js b/Video.ios.js index c494b6c6..0a64dd8b 100644 --- a/Video.ios.js +++ b/Video.ios.js @@ -15,7 +15,9 @@ var Video = React.createClass({ propTypes: { source: PropTypes.string, style: StyleSheetPropType(VideoStylePropTypes), + resizeMode: PropTypes.string, repeat: PropTypes.bool, + pause: PropTypes.bool, }, mixins: [NativeMethodsMixin], @@ -30,18 +32,19 @@ var Video = React.createClass({ var source = this.props.source; var resizeMode; - var contentModes = NativeModules.VideoManager; - if (style.resizeMode === VideoResizeMode.stretch) { - resizeMode = contentModes.ScaleToFill; - } else if (style.resizeMode === VideoResizeMode.contain) { - resizeMode = contentModes.ScaleAspectFit; + if (this.props.resizeMode === VideoResizeMode.stretch) { + resizeMode = NativeModules.VideoManager.ScaleToFill; + } else if (this.props.resizeMode === VideoResizeMode.contain) { + resizeMode = NativeModules.VideoManager.ScaleAspectFit; + } else if (this.props.resizeMode == VideoResizeMode.cover) { + resizeMode = NativeModules.VideoManager.ScaleAspectFill; } else { - resizeMode = contentModes.ScaleAspectFill; + resizeMode = NativeModules.VideoManager.ScaleNone; } var nativeProps = merge(this.props, { style, - resizeMode, + resizeMode: resizeMode, src: source, }); @@ -50,7 +53,8 @@ var Video = React.createClass({ }); var RCTVideo = createReactIOSNativeComponentClass({ - validAttributes: merge(ReactIOSViewAttributes.UIView, {src: true, resizeMode: true, repeat: true}), + validAttributes: merge(ReactIOSViewAttributes.UIView, + {src: true, resizeMode: true, repeat: true, pause: true}), uiViewClassName: 'RCTVideo', }); diff --git a/VideoStylePropTypes.js b/VideoStylePropTypes.js index badebfef..04b4b914 100644 --- a/VideoStylePropTypes.js +++ b/VideoStylePropTypes.js @@ -6,7 +6,6 @@ var ReactPropTypes = require('ReactPropTypes'); var VideoStylePropTypes = { ...LayoutPropTypes, - resizeMode: ReactPropTypes.oneOf(Object.keys(VideoResizeMode)), }; module.exports = VideoStylePropTypes;