Does anyone know how to check if a Youtube video is embeddable using the Youtube API? I\'ve tried using this URL:
http://gdata.youtube.com/feeds/api/videos/4
Looking at the YouTube API reference, it appears you have a couple choices:
Specify the "FORMAT" parameter when searching for a clip:
The format parameter specifies that videos must be available in a particular video format. Your request can specify any of the following formats:
5 - HTTP URL to the embeddable player (SWF) for this video. This format is not available for a video that is not embeddable. Developers commonly add &format=5 to their queries to restrict results to videos that can be embedded on their sites.
Or reference the yt:accessControl element:
The
<yt:accessControl>
tag indicates whether users are allowed to rate a video, add comments about a video, rate comments about the video, add a video response to the video, or embed the video on third-party websites. Another setting indicates whether YouTube can show the video on YouTube properties other than the YouTube.com website.
Syntax would look something like <yt:accessControl action='embed' permission='allowed'/>
So in your example it looks like the line yt:format: "5"
tells you the clip can be embedded.
In YouTube V3 API, to return only videos that are embeddable, add
videoEmbeddable=true
parameter. You must also use type=video
for this to work.
If you can use the new object-free way of showing a video you'll see that almost every video not viewable with the object tag now work flawlessy.
Syntax is:
<iframe class="youtube-player" width="340" height="220" src="http://www.youtube.com/embed/YER_VIDEO_ID_HERE" frameborder="0"></iframe>
You can't trust yt:accessControl at this time.
As of the YouTube V3 API, there is an embeddable
field in the status part.
E.g. https://www.googleapis.com/youtube/v3/videos?id=6CQEZ_kas0I&key=[yourkey]&part=snippet,contentDetails,status
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true
}
The XML should include <yt:noembed/>
if the video isn't embeddable. Example.