react-native-youtube
Advanced tools
Comparing version 0.3.0 to 0.4.0
{ | ||
"name": "react-native-youtube", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A <YouTube/> component for React Native.", | ||
@@ -5,0 +5,0 @@ "main": "YouTube.ios.js", |
@@ -18,3 +18,3 @@ # react-native-youtube | ||
playsInline={true} // control whether the video should play inline | ||
onReady={(e)=>{this.setState({isReady: true})}} | ||
@@ -24,3 +24,3 @@ onChangeState={(e)=>{this.setState({status: e.state})}} | ||
onError={(e)=>{this.setState({error: e.error})}} | ||
style={{alignSelf: 'stretch', height: 300, backgroundColor: 'black', marginVertical: 10}} | ||
@@ -36,2 +36,5 @@ /> | ||
* `playsInline`: Controls whether the video should play inline, or in full screen. | ||
* `modestbranding`: This parameter lets you use a YouTube player that does not show a YouTube logo. Default `false`. | ||
* `controls`: This parameter indicates whether the video player controls are displayed. Supported values are `0`, `1`, `2`. Default `1`. [More information](https://developers.google.com/youtube/player_parameters?hl=en#controls) | ||
* `showinfo`: Setting the parameter's value to false causes the player to not display information like the video title and uploader before the video starts playing. Default `true`. | ||
@@ -44,2 +47,3 @@ ## Events | ||
* `onError`: Sends any errors during video playback on `e.error`. | ||
* `onProgress`: Sends any time progress made on `e.currentTime` and `e.duration`. | ||
@@ -46,0 +50,0 @@ ### Installation |
@@ -33,2 +33,5 @@ /** | ||
playsInline: PropTypes.bool, | ||
showinfo: PropTypes.bool, | ||
modestbranding: PropTypes.bool, | ||
controls: PropTypes.oneOf([0,1,2]), | ||
play: PropTypes.bool, | ||
@@ -64,2 +67,5 @@ hidden: PropTypes.bool, | ||
}, | ||
_onProgress:function(event){ | ||
return this.props.onProgress && this.props.onProgress(event.nativeEvent); | ||
}, | ||
@@ -75,6 +81,7 @@ render() { | ||
onYoutubeVideoError: this._onError, | ||
onYoutubeProgress:this._onProgress | ||
}); | ||
/* | ||
* Try to use `playerParams` instead of settings `playsInline` and | ||
* Try to use `playerParams` instead of settings `playsInline` and | ||
* `videoId` individually. | ||
@@ -89,13 +96,25 @@ */ | ||
nativeProps.playerParams.playerVars = {}; | ||
if (this.props.playsInline) { | ||
nativeProps.playerParams.playerVars = { | ||
playsinline: 1 | ||
}; | ||
nativeProps.playerParams.playerVars.playsinline = 1; | ||
delete nativeProps.playsInline; | ||
}; | ||
if (this.props.modestbranding) { | ||
nativeProps.playerParams.playerVars.modestbranding = 1; | ||
delete nativeProps.modestbranding; | ||
}; | ||
if (this.props.showinfo!==undefined) { | ||
nativeProps.playerParams.playerVars.showinfo = this.props.showinfo ? 1 : 0; | ||
delete nativeProps.showinfo; | ||
}; | ||
if (this.props.controls!==undefined) { | ||
nativeProps.playerParams.playerVars.controls = this.props.controls; | ||
delete nativeProps.controls; | ||
}; | ||
}; | ||
} else { | ||
/* | ||
* For compatibility issues with an older version where setting both | ||
* For compatibility issues with an older version where setting both | ||
* `playsInline` and `videoId` in quick succession would cause the video | ||
@@ -102,0 +121,0 @@ * to sometimes not play. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318464
236
76