Reputation: 985
So I tried using react-native-video package from npm to play a youtube video:
export default class App extends Component {
render() {
return (
<View style={styles.container}>
<Video
source={{uri: 'https://www.youtube.com/watch?v=swigQ10SL_w'}}
style={{ width: 800, height: 800 }}
muted={true}
repeat={true}
resizeMode={"cover"}
volume={1.0}
rate={1.0}
ignoreSilentSwitch={"obey"}
/>
</View>
);
}
}
Upvotes: 2
Views: 4226
Reputation: 4399
By using npm
, install react-native-video
package to your react-native
project.
npm install --save react-native-video
Link the package to platforms iOS
and android
with
react-native link
To link library on iOS
, if they are not linked already do next steps:
In XCode
project navigator, right click on Libraries
folder and choose add files to projectname
option then go to node_modules/react-native-video/ios/
and choose RCTVIdeo.xcodeproj
Go to targets -> Build Phases -> Link Binary With Libraries
hit +
and choose libRCTVideo.a
Strict Note:
Don't play youtube
video in react-native-video
as there is no issue in the code, instead you can try this.
http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4
For youtube
videos
npm install react-native-youtube-player@latest --save
Or
https://www.npmjs.com/package/react-native-youtube
Upvotes: 2