【问题标题】:com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden - YouTube Livecom.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden - YouTube Live
【发布时间】:2021-07-10 18:13:09
【问题描述】:

我是 YouTube API 的新手。我已经在 YouTube 上创建和获取实时事件。但我正在尝试从我的应用开始直播活动,但出现此错误:

 com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
POST https://www.googleapis.com/youtube/v3/liveBroadcasts/transition?broadcastStatus=live&id=m0BCwKmG9Ws&key=AIzaSyCRiIM7Tdb_rqFcGSbQ0jXy0GeODCNSq4g&part=status
{
  "code": 403,
  "errors": [
    {
      "domain": "youtube.liveBroadcast",
      "message": "Stream is inactive",
      "reason": "errorStreamInactive",
      "extendedHelp": "https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition"
    }
  ],
  "message": "Stream is inactive"
}

上线代码

fun startEvent(youtube: YouTube, broadcastId: String?) {
   
    val transitionRequest = youtube.liveBroadcasts().transition(
        "live", broadcastId, "status"
    )
    transitionRequest.key = context.getString(R.string.api_key)
    transitionRequest.execute()
}

我也尝试了this,但仍然遇到同样的问题。 不知道有什么问题?

【问题讨论】:

    标签: android youtube-data-api youtube-livestreaming-api


    【解决方案1】:

    根据LiveBroadcasts.transition API 端点的官方规范:

    在调用此方法之前,您应该确认绑定到您的广播的流的status.streamStatus 属性的值为active

    error specification 内容如下:

    forbidden (403) errorStreamInactive
    当绑定到广播的流处于非活动状态时,不允许请求的转换。

    因此,毫无疑问,在调用 LiveBroadcasts.transition 之前,绑定到直播的直播必须处于活动状态。

    【讨论】:

    • 请告诉我如何将直播状态从即将到来更改为活动?
    • @Τζιότι:一旦您(作为直播的发起者)开始将视频内容发送到 YouTube 直播的提取端点,您的直播就会激活。
    • @Τζιότι:请注意,您的status.streamStatus 不能是upcomingvalid values of this property 是:activecreatederrorinactiveready
    【解决方案2】:

    此错误将通过在创建实时事件时启用自动启动来解决

    val contentDetails = LiveBroadcastContentDetails()
    contentDetails.set("enableAutoStart", true)
    

    【讨论】:

      猜你喜欢
      • 2015-12-05
      • 2015-04-06
      • 1970-01-01
      • 2015-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-10
      • 1970-01-01
      相关资源
      最近更新 更多