Pili Streaming Cloud React Native SDK
Introduction
這 可能
是 第一個
在 React Native 上實作全功能的直播 SDK 了,底層基于Pili-SDK,把 iOS 和 Android 的 API 盡量統一。
2.0 版本為了更容易集成第三方 SDK ,對原有的 React Native 專案進行了改造,iOS 的依賴采用了 Cocoapod 進行管理,當然你也可以采用原來的方式,畢竟是可以共存的。具體可以參考AirApps 可以查看如何進行集成。專案的簡單的例子是react-native-pili
Installation
git clone https://github.com/buhe/pili-startkit YourPorjectName
cd YourPorjectName/js && npm install
cd ../ios && pod install
Javascript
cd YourPorjectName/js
npm start
iOS
Open ios/YourPorjectName.xcworkspace (這里請注意是打開 .xcworkspace!請確認)
Just run your project (Cmd+R)
如果是 iOS 10 需要在 info 中額外添加如下權限:
<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>
<key>NSContactsUsageDescription</key>
<string>contactsDesciption</string>
<key>NSMicrophoneUsageDescription</key>
<string>microphoneDesciption</string>
Android
使用Android Studio打開android
運行醒目
Usage
1. 推流
<Streaming
rtmpURL={"rtmp://pili-publish.pilitest.qiniucdn.com/pilitest/demo_test?key=6eeee8a82246636e"}
style={{
height:400,
width:400,
}}
zoom={1} //zoom
muted={true} //muted
focus={false} //focus
profile={{ //video and audio profile
video:{
fps:30,
bps:1000 * 1024,
maxFrameInterval:48
},
audio:{
rate:44100,
bitrate:96 * 1024
},
started={false} //streaming status
onReady={()=>{}} //onReady event
onConnecting={()=>{}} //onConnecting event
onStreaming={()=>{}} //onStreaming event
onShutdown={()=>{}} //onShutdown event
onIOError={()=>{}} //onIOError event
onDisconnected={()=>{}} //onDisconnected event
/>
2. 直播播放
<Player
source={{
uri:"rtmp://pili-live-rtmp.pilitest.qiniucdn.com/pilitest/xxx",
timeout: 10 * 1000, //live streaming timeout (ms) Android only
live:true, //live streaming ? Android only
hardCodec:false, //hard codec [recommended false] Android only
}}
started={true} //iOS only
muted={false} //iOS only
style={{
height:200,
width:200,
}}
onLoading={()=>{}} //loading from remote or local
onPaused={()=>{}} //pause event
onShutdown={()=>{}} //stopped event
onError={()=>{}} //error event
onPlaying={()=>{}} //play event
/>
uj5u.com熱心網友回復:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/76622.html
標籤:其他技術討論專區
