【问题标题】:detect if embed youtube video down on my webpage检测是否在我的网页上嵌入了 youtube 视频
【发布时间】:2013-10-29 09:33:47
【问题描述】:

如果我在我的网页上嵌入 youtube 视频,是否可以使用 jquery/javascript 检测视频已关闭(由于版权或用户关闭视频)?

感谢您的帮助。

【问题讨论】:

    标签: jquery youtube youtube-api


    【解决方案1】:

    您可以使用 YouTube Data API v3 使用 javascript 检索视频数据:

    https://developers.google.com/youtube/v3/docs/videos

    您可以检查视频是否存在,尝试检索视频数据:

    https://developers.google.com/youtube/v3/docs/videos/list

    检索视频数据后,您可以验证以下字段:

    contentDetails.regionRestriction
    
    The regionRestriction object contains information about the countries where a video is (or is not) viewable. The object will contain either the contentDetails.regionRestriction.allowed property or the contentDetails.regionRestriction.blocked property.
    
    contentDetails.regionRestriction.allowed[]
    
    A list of region codes that identify countries where the video is viewable. If this property is present and a country is not listed in its value, then the video is blocked from appearing in that country. If this property is present and contains an empty list, the video is blocked in all countries.
    
    contentDetails.regionRestriction.blocked[]
    
    A list of region codes that identify countries where the video is blocked. If this property is present and a country is not listed in its value, then the video is viewable in that country. If this property is present and contains an empty list, the video is viewable in all countries.
    

    【讨论】:

      猜你喜欢
      • 2018-01-07
      • 2011-12-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-04
      • 2016-03-20
      • 1970-01-01
      • 2012-01-02
      • 2012-12-16
      相关资源
      最近更新 更多