1
votes

YouTube channels can disallow their videos to be played in an embedded YouTube player. I'm working with user generated content, where the user chooses a video of their choice to be embedded (with the YouTube iFrame API), and I need to explain to the user why their video cant be embedded, so I need to detect this specific reason for failure, rather than simply detecting that the video wont play. I want to check this before actually feeding the video to the player.


I'm wondering if I can get the info as a response to a v3 data query like the one I'm currently doing:

$.getJSON('https://www.googleapis.com/youtube/v3/videos?key=***&part=snippet,contentDetails,statistics&id=' + videoID, function(data, status, xhr) { ...

I saw something like this talked about involving the v2 data API, here.

Is there a way to check whether the video is restricted from being played as an embed beforehand?

1

1 Answers

2
votes

You should be getting an onError 101 event.

You can also filter videos using videoEmbeddable in a search.