【发布时间】:2020-03-26 23:31:19
【问题描述】:
可以使用 Youtube Data API 在 React Native 中将视频上传到 Youtube。ReactNative 可以进行 YouTube 直播吗?
【问题讨论】:
标签: react-native react-native-android react-native-ios youtube-livestreaming-api
可以使用 Youtube Data API 在 React Native 中将视频上传到 Youtube。ReactNative 可以进行 YouTube 直播吗?
【问题讨论】:
标签: react-native react-native-android react-native-ios youtube-livestreaming-api
Youtube 有 RTMP 端点(和备份端点),例如 rtmp://a.rtmp.youtube.com/live2。 rtmp直播发布需要一个工具(库),如ffmpeg、gstreamer、rtmplib等。然后你可以很容易地从reactnative或native或javascript调用库的方法。只需要获取stream key,然后调用带有有效参数的方法。
【讨论】:
安装:
npm install react-native-live-stream --save
示例代码:
import {LivePlayer} from "react-native-live-stream";
<LivePlayer
source={{ uri: 'rtmp://a.rtmp.youtube.com/live2/FOO-KEY' }} //enter your url here
ref={(ref) => { this.player = ref }}
style={livestyle.video}
paused={false}
muted={false}
bufferTime={300}
maxBufferTime={1000}
resizeMode={"contain"}
onLoading={() => { console.log('loading...') }}
onLoad={() => { console.log('onLoad') }}
onEnd={() => { }}
/>