检查 YouTube 视频是直播还是上传

我有一个 YouTube 直播活动.我可以使用 YouTube IFrame Player API 播放视频.我想知道是否有任何方法可以找到视频是现场活动视频还是常规上传的视频.我需要这些信息来设计我的控件.

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.

推荐答案

(目前)您可以做到这一点的唯一方法是使用 youtube 后端 api.根据视频 ID 获取有关视频的数据,并且在响应中您有一个 snippet.liveBroadcastContent 属性,该属性可以是 live、none 或即将到来的.

The 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 upcoming.

相关文章