所以我尝试使用 npm 中的 React-native-video 包来播放 YouTube 视频:
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>
);
}
}
I get an error:
通过使用npm
, 安装react-native-video
打包到你的react-native
项目。
npm install --save react-native-video
将包链接到平台iOS
and android
with
react-native link
链接库iOS
,如果它们尚未链接,则已执行后续步骤:
In XCode
项目导航器,右键单击Libraries
文件夹并选择add files to projectname
选项然后转到node_modules/react-native-video/ios/
并选择RCTVIdeo.xcodeproj
Go to targets -> Build Phases -> Link Binary With Libraries
hit +
并选择libRCTVideo.a
严格注意:
不要玩youtube
视频输入react-native-video
由于代码没有问题,您可以尝试一下。http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4 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 https://www.npmjs.com/package/react-native-youtube
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)