Embed YouTube Live Streaming Automatically

2019-04-12 08:33发布

问题:

How to embed an YouTube live streaming automatically in an webpage using php?

Something like querying the video at https://youtube.com/user/USERID/live when a transmission is on air?

回答1:

You can easily do it with using search->list method by setting type=video and eventType=live

Here is another PHP search code sample that will get you started.



回答2:

I am the author of the OP. I wrote this PHP class, maybe it will be useful for some so I'll link here:

https://github.com/iacchus/youtube-live-embed

It allows one to query a channel and embed the Live Streaming if there is one. May take some seconds or even minutes to YouTube API response to show the live streaming after the streaming is On Air.