youtubeembedyoutube-apiswfobject

How can I tell if a YouTube video is embeddable before I try and load it?


I've got a chromless YouTube player that I'm trying to load videos into, but only some videos work--not all. If I'm not mistaken, the ones that aren't loading are due to copyright infringement (e.g., some episode of a cartoon doesn't load, but a home movie of a kid doing a backflip does). What I'm trying to do is either find out whether or not these videos can load, either after we try to load them or before.

As an example, here are two videos by Nataly Dawn. One loads, the other doesn't.

// loads and plays the video
ytplayer.loadVideoById("GhDGdT33K0k");

// doesn't load/play the video
ytplayer.loadVideoById("-KYUPJIzCyM");

From looking at the data of both the working video and the non-working video, I can't seem to see anything that would indicate that the latter is non-embeddable. [I'm looking for <yt:accessControl> tags or a missing yt:format='5' (cf. How do I use the Youtube API to check if a video is embeddable?), but to no avail.]

From what I've tried in the console, loadVideoById always returns undefined, regardless of whether or not the video actually loads. I can't seem to find an API method to determine whether or not the video has done so.


Solution

  • Both videos you mentioned appear to be loadable and playable for me. For example use: the google code playground and insert your videos into the option tags of the HTML.

    Here's a few tips though.