无法使用 Youtube 将我的 Youtube 广播转换为直播 API

Cannot make transition of my Youtube broadcast to live using Youtube API

现在我正在尝试弄清楚在将我的 YouTube 广播转为直播时我做错了什么。

所以我发出请求并得到以下响应:

{
  "code" : 403,
  "errors" : [ {
    "domain" : "youtube.liveBroadcast",
    "message" : "Invalid transition",
    "reason" : "invalidTransition",
    "extendedHelp" : "https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition#params"
  } ],
  "message" : "Invalid transition"
}

当然我已经阅读了很多次文档,所以我监控了 LiveStream 并等待它的 "active" 状态(我的广播有 lifeCycleStatus="ready")。

错误消息没有解释我无法进行转换的真正原因。
而且...当然我无法访问 Youtube 服务器的日志 :)

你有什么建议?
如何找出我错在哪里?

所以即使我错过了什么,文档和错误消息也无法帮助我理解任何东西。所以无论如何,对于 YT LiveStreaming API...

来说,它是一种 "bug"

所以有点不清楚的规则是:

  1. 确保您已创建并准备好广播和直播。
    并确保广播生命周期状态不是 COMPLETE, 否则重新创建广播 ...因此请确保您的广播生命周期状态为 ready
  2. 直播绑定直播
  3. 开始发布视频到直播
  4. 等待直播状态active
  5. 过渡到 testing(是的,你必须这样做而不是移动到 live
  6. 等待广播lifeCycleStatus变成testing
  7. 过渡到live
  8. 等待广播lifeCycleStatus变成live

您不能跳过 testing,也不能从 complete 过渡到 testingready

我遇到了同样的问题,终于找到问题所在了。 post命令转为testing后,lifeCycleStatus为:liveStarting,需要等待lifeCycleStatus转为testing。所以我们应该获得广播状态。 这是我的代码:

liveStreamRequest = youtube.liveStreams()
                    .list("id,status")
                    .setId(liveBroadcast.getContentDetails()
                            .getBoundStreamId());
            LiveStreamListResponse returnedList = liveStreamRequest.execute();
            List<LiveStream> liveStreams = returnedList.getItems();
            if (liveStreams != null && liveStreams.size() > 0) {
                LiveStream liveStream = liveStreams.get(0);
                if (liveStream != null)
                    while (!liveStream.getStatus().getStreamStatus()
                            .equals("active")) {
                        Thread.sleep(1000);
                        returnedList = liveStreamRequest.execute();
                        liveStreams = returnedList.getItems();
                        liveStream = liveStreams.get(0);
                    }
            }

希望能帮到关心这个问题的人!

如果出现以下情况,您可以离开 4-7 步: 在创建或更新该广播时,通过将 contentDetails.monitorStream.enableMonitorStream 属性 设置为 false 来禁用广播的监控流。