dongpai1942 2016-10-31 18:21
浏览 700
已采纳

YouTube受限制的播放问题

I'm unable to embed certain YT videos.

The error I'm receiving is as follows:

The video contains content from VEVO, who has blocked it from display on this website.

I do not believe it's simply restricting embeds as the video I'm testing with shows up, embeded on other sites such as:

http://youtubeonrepeat.com/watch/?v=fk4BbF7B29w

I'm using the YouTube IFRAME API to load the video and I've attempted to embed the video using playervars such as "origin" and "enablejsapi" to no avail.

Example:

  var player;
  function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
      height: '390',
      width: '640',
      videoId: 'fk4BbF7B29w',
      playerVars: {
        'origin': 'https://api.specivid.com',
        'enablejsapi' : 1
      },
      events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange
      }
    });
  }

Am I just SOL or am I missing something?

The page I am testing the embed on is: https://api.specivid.com/test.php

Thank you.

  • 写回答

1条回答 默认 最新

  • dpir3950 2016-11-01 08:21
    关注

    I think it would help if you read Understand Playback Restrictions.

    With enhanced content controls comes increased complexity. The only foolproof way to determine if a user has access to watch a video is to ask them to try watching it. So, if you’re writing an application and you’d like to prevent users from seeing videos that they don’t have the ability to watch, here are a list of things to check:

    1. yt:accessControl

    Videos that are available for embedding on third-party applications will have the following:

    <yt:accesscontrol action='embed' permission='allowed' />
    

    If you’d like to only search for videos that are embeddable, add format=5 to your query. Just as a video can be embeddable or not, it can also be syndicatable or not:

    <yt:accesscontrol action='syndicate' permission='allowed' />
    

    A video that is embeddable but not syndicatable will play on YouTube.com or on other sites that embed the YouTube player, but may not play on devices such as mobile phones or TVs. If you’d like to learn more about retrieving videos suitable for playback on mobile devices, see the developer’s guide.

    1. Geo Restrictions

    Some videos may be restricted in certain countries. This restriction applies to where the viewer is located, not where your third-party server is located. For instance, if a video is blocked in the US, it will have the following:

    <media:restriction type='country'
      relationship='deny'>US</media:restriction>
    

    When you make a query, you can add a restriction parameter to filter videos that will not be playable by a client with a specific IP or from a specific country.

    1. yt:state

    It’s also important to check the yt:state of the video in the API response. Even if yt:accessControl indicates that syndication is allowed, yt:state might override it. For example, a video that has limited syndication would have the following:

    <app:control>
      <yt:state name='restricted' reasoncode='limitedSyndication'>
        Syndication of this video was restricted by its owner.
      </yt:state>
    </app:control>
    

    You might also see the message, “Syndication of this video was restricted by the content owner.” Hence, even if the uploader allows syndication, the content owner could override that and disallow syndication. For example, this could happen if someone uploads a video that contains a soundtrack that is owned by another content owner.

    1. Rentals

    Some YouTube videos are rentals. You can tell that they are rentals because they have a media:price tag:

    <media:price type='rent' price='1.99' currency='USD' yt:duration='PT2592000S' />
    

    Note that the media:price tag is only included in the response if you use a developer key in the query. If you are building a non-browser based YouTube application where it would be impossible for the user to rent a video, you might want to filter out the rentals. You can do that by passing the parameter paid-content=false.

    1. Other Restrictions not Currently Exposed via the API

    There are even more subtle restrictions that occasionally come into play. Not all of these are currently queryable via the API. For instance, some videos are only playable on a certain set of domains. As I mentioned above, the only foolproof way to know if a user has access to watch a video is to have them try watching it.

    Also, check the Youtube guide on Embed a player using an <iframe> tag.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?