React Native视频播放(iOS)
发布时间:2020-12-15 04:38:52 所属栏目:百科 来源:网络整理
导读:网站链接:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/learn-react-native-video/ React Native项目中插入视频播放的简单教程(iOS)。 在你的项目中执行以下步骤: 1.运行npm install react-native-video --save 2.iOS下: (1)在Xcode中打
网站链接:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/learn-react-native-video/ React Native项目中插入视频播放的简单教程(iOS)。 在你的项目中执行以下步骤: 1.运行npm install react-native-video --save2.iOS下:(1)在Xcode中打开你的项目,在名字为Libraries上点右键,然后点击Add Files to "Your Project Name";
(2)添加libRTCVideo.a到Build Phases -> Link Binary With Libraries
(3)添加项目中的.mp4格式的视频文件到Build Phases -> Copy Bundle Resources (4)在你的项目中使用以下命令就可以得到你想引用的视频: 调用视频用法:
//Withinyourrenderfunction,assumingyouhaveafilecalled //"background.mp4"inyourproject.Youcanincludemultiplevideos //onasinglescreenifyoulike.<Videosource={{uri:"background"}}//CanbeaURLoralocalfile. rate={1.0}//0ispaused,1isnormal. volume={1.0}//0ismuted,1isnormal. muted={false}//Mutestheaudioentirely. paused={false}//Pausesplaybackentirely. resizeMode="contain"//Fillthewholescreenataspectratio. repeat={true}//Repeatforever. onLoadStart={this.loadStart}//Callbackwhenvideostartstoload onLoad={this.setDuration}//Callbackwhenvideoloads onProgress={this.setTime}//Callbackevery~250mswithcurrentTime onEnd={this.onEnd}//Callbackwhenplaybackfinishes onError={this.videoError}//Callbackwhenvideocannotbeloaded style={styles.backgroundVideo}/>//Lateroninyourstyles.. varstyles=Stylesheet.create({ backgroundVideo:{ position:'absolute',top:0,left:0,bottom:0,right:0,},}); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |