Socket
Socket
Sign inDemoInstall

react-native-youtube

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-youtube - npm Package Compare versions

Comparing version 0.7.2 to 0.8.0

main.js

11

package.json
{
"name": "react-native-youtube",
"version": "0.7.2",
"version": "0.8.0",
"description": "A <YouTube/> component for React Native.",
"main": "YouTube.ios.js",
"main": "main.js",
"scripts": {

@@ -23,3 +23,8 @@ "test": "echo \"Error: no test specified\" && exit 1"

},
"homepage": "https://github.com/paramaggarwal/react-native-youtube#readme"
"homepage": "https://github.com/paramaggarwal/react-native-youtube#readme",
"rnpm": {
"android": {
"packageInstance": "new ReactNativeYouTube()"
}
}
}

@@ -46,2 +46,3 @@ # react-native-youtube [![react-native-youtube](http://img.shields.io/npm/dm/react-native-youtube.svg)](https://www.npmjs.org/package/react-native-youtube) [![npm version](https://badge.fury.io/js/react-native-youtube.svg)](http://badge.fury.io/js/react-native-youtube) [![Dependency Status](https://david-dm.org/inProgress-team/react-native-youtube.svg)](https://david-dm.org/inProgress-team/react-native-youtube)

* `origin`: This parameter provides an extra security measure for the IFrame API.
* `apiKey`: This parameter is required on Android for the YouTube API to work.

@@ -62,2 +63,3 @@ ## Events

##### IOS
(requires react-native >= 0.6.0)

@@ -69,3 +71,47 @@

##### Android : rnpm is not working yet !!
In node_module :
`$ git clone https://github.com/inProgress-team/react-native-youtube.git`
Then add in settings.gradle :
```
include ':RCTYouTube', ':app'
project(':RCTYouTube').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-youtube/RCTYouTube')
```
In build.gradle :
```
dependencies {
[...]
compile project(':RCTYouTube') // From node_modules
}
```
In MainApplication.java :
```
import com.inprogress.reactnativeyoutube.ReactNativeYouTube;
[...]
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeYouTube()
);
}
```
##### OPTIONAL : Activated sound when phone is on vibrate mode
Open AppDelegate.m and add :
* `#import <AVFoundation/AVFoundation.h>`
* `[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error: nil];` in your didFinishLaunchingWithOptions method
## Example

@@ -72,0 +118,0 @@ Try the included `RCTYouTubeExample`:

@@ -8,10 +8,141 @@ /**

var warning = require('warning');
import React, { Component, PropTypes } from 'react';
import ReactNative, {
View,
StyleSheet,
requireNativeComponent,
NativeModules,
NativeMethodsMixin
} from 'react-native';
var YouTube = {
test: function() {
warning("Not yet implemented for Android.");
const RCTYouTube = requireNativeComponent('ReactYouTube', YouTube,
{
nativeOnly: {onError:true,
onReady:true,
onChangeState:true,
onChangeQuality:true
}
});
export default class YouTube extends Component {
static propTypes = {
style: View.propTypes.style,
videoId: PropTypes.string.isRequired,
apiKey: PropTypes.string.isRequired,
playsInline: PropTypes.bool,
showinfo: PropTypes.bool,
modestbranding: PropTypes.bool,
controls: PropTypes.oneOf([0,1,2]),
origin: PropTypes.string,
play: PropTypes.bool,
rel: PropTypes.bool,
hidden: PropTypes.bool,
onReady: PropTypes.func,
onChangeState: PropTypes.func,
onChangeQuality: PropTypes.func,
onError: PropTypes.func,
loop: PropTypes.bool,
};
static defaultProps = {
loop: false
};
constructor(props) {
super(props);
this._exportedProps = NativeModules.YouTubeManager && NativeModules.YouTubeManager.exportedProps;
}
};
module.exports = YouTube;
_onReady(event) {
return this.props.onReady && this.props.onReady(event.nativeEvent);
}
_onChangeState(event) {
if(event.nativeEvent.state == 'ended' && this.props.loop) {
this.seekTo(0);
}
return this.props.onChangeState && this.props.onChangeState(event.nativeEvent);
}
_onChangeQuality(event) {
return this.props.onChangeQuality && this.props.onChangeQuality(event.nativeEvent);
}
_onError(event) {
return this.props.onError && this.props.onError(event.nativeEvent);
}
_onProgress(event){
return this.props.onProgress && this.props.onProgress(event.nativeEvent);
}
seekTo(seconds){
NativeModules.YouTubeModule.seekTo(parseInt(seconds, 10));
//this.refs.youtubePlayer.seekTo(ReactNative.findNodeHandle(this), parseInt(seconds, 10));
}
render() {
var style = [styles.base, this.props.style];
var nativeProps = Object.assign({}, this.props);
nativeProps.style = style;
nativeProps.onYoutubeVideoReady = this._onReady.bind(this);
nativeProps.onYoutubeVideoChangeState = this._onChangeState.bind(this);
nativeProps.onYoutubeVideoChangeQuality = this._onChangeQuality.bind(this);
nativeProps.onYoutubeVideoError = this._onError.bind(this);
nativeProps.onYoutubeProgress = this._onProgress.bind(this);
/*
* Try to use `playerParams` instead of settings `playsInline` and
* `videoId` individually.
*/
if (this._exportedProps) {
if (this._exportedProps.playerParams) {
nativeProps.playerParams = {
videoId: this.props.videoId,
};
delete nativeProps.videoId;
nativeProps.playerParams.playerVars = {};
if (this.props.playsInline) {
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;
};
if (this.props.origin!==undefined) {
nativeProps.playerParams.playerVars.origin = this.props.origin;
delete nativeProps.origin;
};
if (this.props.rel!==undefined) {
nativeProps.playerParams.playerVars.rel = this.props.rel ? 1 : 0;
delete nativeProps.rel;
};
};
} else {
/*
* For compatibility issues with an older version where setting both
* `playsInline` and `videoId` in quick succession would cause the video
* to sometimes not play.
*/
delete nativeProps.playsInline;
}
return <RCTYouTube {... nativeProps} />;
}
}
const styles = StyleSheet.create({
base: {
overflow: 'hidden',
},
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc