YouTube 流媒体

YouTube streaming

在 YouTube 流式传输中 API 我们可以创建广播和流式传输,但我如何真正开始流式传输?

我的意思是,当我们用浏览器创建广播时,我们必须先点击"preview button"。当 YouTube 收到流媒体内容时,我们可以点击 "broadcast button"。

对此的等效 API 调用是什么?指向 Java、Python 或 PHP API 对我来说都很好,谢谢。

POST https://www.googleapis.com/youtube/v3/liveBroadcasts/transition

将 broadcastStatus 设置为直播时,您将开始直播。将其设置为测试时,YouTube 仅将视频传输到广播的监视器流。

这里有更多信息https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition

作为直播过渡状态的documentation

Changes the status of a YouTube live broadcast and initiates any processes associated with the new status. For example, when you transition a broadcast's status to testing, YouTube starts to transmit video to that broadcast's monitor stream. Before calling this method, you should confirm that the value of the status.streamStatus property for the stream bound to your broadcast is active.

broadcastStatus 参数标识广播正在更改的状态。请注意,要将广播转换为测试或直播状态,status.streamStatus 必须对广播绑定到的流有效。

broadcastStatus 参数的可接受值是:

  • complete – 广播结束。 YouTube 停止传输视频。
  • live – 观众可以看到广播。 YouTube 传输 视频到广播的监视器流及其广播流。
  • testing – 开始测试广播。 YouTube 将视频传输到 广播的监听流。请注意,您只能转换一个 如果它广播到测试状态 contentDetails.monitorStream.enableMonitorStream 属性 设置为 是的。