Playing 'watch_popup videos' using the YouTube Api for embedding videos


YouTube offers users to view their videos in 'popup mode', thus allowing them to watch videos without the annoying comments and ads. Another good thing about watch_popup videos is that YouTube doesn't impose constraints on their width and height. So we'll never see 'video too small' (instead of the real video) when we create very small videos.

The Future of Embedding.
Urls for watch_popup videos typically look like http://www.youtube.com/watch_popup?v=VIDEO_ID. We can force the videos to play in a given quality by adding the appropriate parameter to the URL, like this (for instance): http://www.youtube.com/watch_popup?v=VIDEO_ID&tamp;vq=large ('large'= 480p). We can also skip part of the video by providing the appopriate parameter for its start point: http://www.youtube.com/watch_popup?v=VIDEO_ID&tamp;vq=large&tamp;start=some_integer. We can even create playlists. Here's a real world example: http://www.youtube.com/watch_popup?v=AVgbEkBWuqs&tamp;vq=large&tamp;start=2&tamp;playlist=bHQqvYy5KYo,GBaHPND2QJg. This will play 3 videos with ID=AVgbEkBWuqs, bHQqvYy5KYo and GBaHPND2QJg, respectively.

There are also things that watch_popup videos won't allow. We can't force them to NOT SHOW thumbnails for suggested videos (at the end of the video) by simply adding &tamp;rel=0 to the url. And we can't force an end point for watch_popup videos by adding &tamp;end=some_integer. But - fortunately enough- the YouTube Player API for Iframe Embeds lets us embed watch_popup videos (althought it was not specifically designed for this). So the question is: can we use the YouTube Player API for hiding suggested videos at the end of watch_popups and for creating end points for those videos?

I created a script proving that this is indeed possible (but see below for a complication pertaining to playlists). I put the script in a file called watch_popup_yt_api.js (click to see what must be put inside it). To make it work, please do the following:
Further explanations / remarks:

© Arie Molendijk, mesdomaines.nu.