mfragale
mfragale

Reputation: 139

Youtube Live Broadcast Status

I am going to embed a Youtube live event on my site. I want to be able to output the Broadcast Status. So if the event is on hold, I want to display "On Hold", if it's live, I want to display "Live", if it's over, I want to display "Event is Over", etc.

Is this possible?

Upvotes: 1

Views: 1125

Answers (2)

JAL
JAL

Reputation: 42449

This is possible with the liveBroadcasts/list endpoint.

part -> id, status

id -> The Video ID if your Live Broadcast object

HTTP GET: GET https://www.googleapis.com/youtube/v3/liveBroadcasts?part=id%2Cstatus&id={video_id}&key={YOUR_API_KEY}

The status dictionary returned might look something like this:

"status": {
    "lifeCycleStatus": "complete",
    "privacyStatus": "unlisted",
    "recordingStatus": "recorded"
}

The value for the lifeCycleStatus is what you're looking for. This can be one of several values:

  • abandoned – This broadcast was never started.

  • complete – The broadcast is finished.

  • created – The broadcast has incomplete settings, so it is not ready to transition to a live or testing status, but it has been created and is otherwise valid.

  • live – The broadcast is active.

  • liveStarting – The broadcast is in the process of transitioning to live status.

  • ready – The broadcast settings are complete and the broadcast can transition to a live or testing status.

  • reclaimed – This broadcast has been reclaimed.

  • revoked – This broadcast was removed by an admin action.

  • testStarting – The broadcast is in the process of transitioning to testing status.

  • testing – The broadcast is only visible to the partner.

Upvotes: 1

NitinG
NitinG

Reputation: 923

It is possible but you need to map the status depending upon the data is coming thorough your stream or not. It will all depends on how you are tracking the YouTube traffic on your webpage.

Upvotes: 0

Related Questions