【问题标题】:Is YouTube live streaming possible with ReactNative?使用 React Native 可以进行 YouTube 直播吗?
【发布时间】: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


    【解决方案1】:

    Youtube 有 RTMP 端点(和备份端点),例如 rtmp://a.rtmp.youtube.com/live2。 rtmp直播发布需要一个工具(库),如ffmpeg、gstreamer、rtmplib等。然后你可以很容易地从reactnative或native或javascript调用库的方法。只需要获取stream key,然后调用带有有效参数的方法。

    【讨论】:

    【解决方案2】:

    react-native-live-stream 可用,

    安装:

    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={() => { }}
    />
    

    【讨论】:

    猜你喜欢
    • 2021-06-15
    • 2015-05-23
    • 2020-07-26
    • 2014-12-18
    • 1970-01-01
    • 2015-01-25
    • 2016-11-25
    • 2016-01-27
    • 1970-01-01
    相关资源
    最近更新 更多