I have a YouTube Live Event. I am able to play the video using the YouTube IFrame Player API. I want to know if there is any way that I can find if the video is a Live event video or a regular uploaded video. I need this information for designing my controls.
I have a YouTube Live Event. I am able to play the video using the YouTube IFrame Player API. I want to know if there is any way that I can find if the video is a Live event video or a regular uploaded video. I need this information for designing my controls.
Share Improve this question edited Feb 25, 2016 at 14:13 JAL 42.5k23 gold badges176 silver badges311 bronze badges asked Jan 7, 2016 at 2:43 MoniMoni 1311 gold badge2 silver badges5 bronze badges 3- 1 Use player.getDuration(). If it is live stream, it will return 0 Demo – Vuong Commented Jan 7, 2016 at 4:01
- 1 Thank you. But, If I try getDuration() before the video even starts playing. Here, isn't there a chance that getDuration() returns 0 for an uploaded video? "Note that getDuration() will return 0 until the video's metadata is loaded, which normally happens just after the video starts playing" – Moni Commented Jan 7, 2016 at 5:08
- Hey Moni, any updates? Did my answer help you? – JAL Commented Jan 21, 2016 at 20:50
2 Answers
Reset to default 7The only way you can do this (currently) is with youtube backend api.
Get data about the video based on its id and in the response you have a property snippet.liveBroadcastContent
which is either live, none, or uping.
The IFrame API provides a Playback quality function which returns a string representation of the current video quality.
From my tests, this function will return an undocumented string auto
for live events.
Related discussion can be found in this issue on YouTube's iOS Player Helper Library's GitHub page.