Unable to translate my Youtube broadcast to live using the Youtube API.

Right now I'm trying to understand what I'm doing wrong when I switch to broadcasting my YT broadcast in order to live.

So, I make a request and get the following response:

{ "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" } 

Of course, I read the documents many times, so I controlled the LiveStream and waited for its “active” state (and my broadcast has lifeCycleStatus = “ready”).

The error message does not explain the real reason why I cannot make the transition.
And ... of course, I do not have access to Youtube server logs :)

What can you offer?
How to find out where I am wrong?

So, even if I missed something, the documents and the error message do not help me understand anything. Anyway, this is a kind of “bug” for the YT LiveStreaming API ...

+5
source share
3 answers

So, a little fuzzy rule:

  • make sure that you are created and ready for broadcast and live streams.
    and make sure the broadcast life cycle status is not COMPLETE , otherwise recreate the broadcast ... so make sure your broadcast life cycle is ready
  • link livestream
  • start publishing video on livestream
  • waiting for livestream active status
  • switching to testing (yes, you should do this instead of switching to live )
  • wait for the broadcast of lifeCycleStatus become testing
  • transition to live
  • wait for the broadcast of lifeCycleStatus become live

You cannot skip testing and cannot switch from COMPLETE to testing or ready .

+11
source

I answer the same question, finally I found the problem. After the transon post-team for testing, lifeCycleStatus: liveStarting, we need to expect lifeCycleStatus to be tested. Therefore, we must get the status of the broadcast. here is my code:

 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); } } 

Hope to help someone take care of this problem!

+1
source

You can leave 4-7 steps if: the stream of the broadcast monitor was disabled by setting the property contentDetails.monitorStream.enableMonitorStream false when creating or updating this broadcast.

0
source

Source: https://habr.com/ru/post/1241449/


All Articles