Move resizeMode to prop from style (at request of @vjeux) and add pause
prop
This commit is contained in:
parent
b8df485c79
commit
011ecff875
@ -34,6 +34,15 @@
|
|||||||
_playerLayer.videoGravity = mode;
|
_playerLayer.videoGravity = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setPause:(BOOL)wantsToPause
|
||||||
|
{
|
||||||
|
if (wantsToPause) {
|
||||||
|
[_player pause];
|
||||||
|
} else {
|
||||||
|
[_player play];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)playerItemDidReachEnd:(NSNotification *)notification {
|
- (void)playerItemDidReachEnd:(NSNotification *)notification {
|
||||||
AVPlayerItem *item = [notification object];
|
AVPlayerItem *item = [notification object];
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
RCT_EXPORT_VIEW_PROPERTY(src, NSString);
|
RCT_EXPORT_VIEW_PROPERTY(src, NSString);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString);
|
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL);
|
RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL);
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(pause, BOOL);
|
||||||
|
|
||||||
- (NSDictionary *)constantsToExport
|
- (NSDictionary *)constantsToExport
|
||||||
{
|
{
|
||||||
|
20
Video.ios.js
20
Video.ios.js
@ -15,7 +15,9 @@ var Video = React.createClass({
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
source: PropTypes.string,
|
source: PropTypes.string,
|
||||||
style: StyleSheetPropType(VideoStylePropTypes),
|
style: StyleSheetPropType(VideoStylePropTypes),
|
||||||
|
resizeMode: PropTypes.string,
|
||||||
repeat: PropTypes.bool,
|
repeat: PropTypes.bool,
|
||||||
|
pause: PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [NativeMethodsMixin],
|
mixins: [NativeMethodsMixin],
|
||||||
@ -30,18 +32,19 @@ var Video = React.createClass({
|
|||||||
var source = this.props.source;
|
var source = this.props.source;
|
||||||
|
|
||||||
var resizeMode;
|
var resizeMode;
|
||||||
var contentModes = NativeModules.VideoManager;
|
if (this.props.resizeMode === VideoResizeMode.stretch) {
|
||||||
if (style.resizeMode === VideoResizeMode.stretch) {
|
resizeMode = NativeModules.VideoManager.ScaleToFill;
|
||||||
resizeMode = contentModes.ScaleToFill;
|
} else if (this.props.resizeMode === VideoResizeMode.contain) {
|
||||||
} else if (style.resizeMode === VideoResizeMode.contain) {
|
resizeMode = NativeModules.VideoManager.ScaleAspectFit;
|
||||||
resizeMode = contentModes.ScaleAspectFit;
|
} else if (this.props.resizeMode == VideoResizeMode.cover) {
|
||||||
|
resizeMode = NativeModules.VideoManager.ScaleAspectFill;
|
||||||
} else {
|
} else {
|
||||||
resizeMode = contentModes.ScaleAspectFill;
|
resizeMode = NativeModules.VideoManager.ScaleNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nativeProps = merge(this.props, {
|
var nativeProps = merge(this.props, {
|
||||||
style,
|
style,
|
||||||
resizeMode,
|
resizeMode: resizeMode,
|
||||||
src: source,
|
src: source,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -50,7 +53,8 @@ var Video = React.createClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
var RCTVideo = createReactIOSNativeComponentClass({
|
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',
|
uiViewClassName: 'RCTVideo',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ var ReactPropTypes = require('ReactPropTypes');
|
|||||||
|
|
||||||
var VideoStylePropTypes = {
|
var VideoStylePropTypes = {
|
||||||
...LayoutPropTypes,
|
...LayoutPropTypes,
|
||||||
resizeMode: ReactPropTypes.oneOf(Object.keys(VideoResizeMode)),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = VideoStylePropTypes;
|
module.exports = VideoStylePropTypes;
|
||||||
|
Loading…
Reference in New Issue
Block a user