溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

React Native視頻播放(iOS)

發(fā)布時間:2020-06-25 01:05:16 來源:網(wǎng)絡 閱讀:628 作者:maoyazhi 欄目:移動開發(fā)

網(wǎng)站鏈接:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/learn-react-native-video/

React Native項目中插入視頻播放的簡單教程(iOS)。

在你的項目中執(zhí)行以下步驟:

1.運行npm install react-native-video --save
2.iOS下:

(1)在Xcode中打開你的項目,在名字為Libraries上點右鍵,然后點擊Add Files to "Your Project Name";

React Native視頻播放(iOS) React Native視頻播放(iOS)

(2)添加libRTCVideo.a到 Build Phases -> Link Binary With Libraries 

React Native視頻播放(iOS)

(3)添加 項目中的.mp4 格式的視頻文件到 Build Phases -> Copy Bundle Resources

React Native視頻播放(iOS)

(4)在你的項目中使用以下命令就可以得到你想引用的視頻:

調用視頻用法:

React Native視頻播放(iOS)

// Within your render function, assuming you have a file called
// "background.mp4" in your project. You can include multiple videos
// on a single screen if you like.<Video source={{uri: "background"}} // Can be a URL or a local file.
       rate={1.0}                   // 0 is paused, 1 is normal.
       volume={1.0}                 // 0 is muted, 1 is normal.
       muted={false}                // Mutes the audio entirely.
       paused={false}               // Pauses playback entirely.
       resizeMode="contain"           // Fill the whole screen at aspect ratio.
       repeat={true}                // Repeat forever.
       onLoadStart={this.loadStart} // Callback when video starts to load
       onLoad={this.setDuration}    // Callback when video loads
       onProgress={this.setTime}    // Callback every ~250ms with currentTime
       onEnd={this.onEnd}           // Callback when playback finishes
       onError={this.videoError}    // Callback when video cannot be loaded
       style={styles.backgroundVideo} />// Later on in your styles..
var styles = Stylesheet.create({
  backgroundVideo: {
    position: 'absolute',
    top: 0,
    left: 0,
    bottom: 0,
    right: 0,
  },
});


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI