We have YouTube videos on a site and want to detect if it is likely that they will not be able to view them due to (mostly likely) company policy or otherwise.
We have two sites:
1) Flex / Flash 2) HTML
I think with Flex I can attempt to download http://youtube.com/crossdomain.xml and if it is valid XML assume the site is available
But with HTML I don't know how to do it. I can't even think of a 'nice hack'.
I got stuck on this today and tried the favicon test but it wasnt working in IE. I was using the YouTube Player API Reference for iframe Embeds to embed youtube videos into my site so what I did is perform a check on the player var defined just before the onYouTubeIFrameReady with a delay on the javascript call.
Seems to work for me. I needed the delay to get it to work in IE.
I like lacker's solution, but yes, it creates a race condition. This will work and won't create a race contition:
This should work. Basically, it loads a youtube.com javascript file, then checks if a function in that file exists.
You can load an image from youtube using javascript and check its properties. The favicon is tiny and has a consistent url -
I think this is slightly better than loading javascript because this won't try to run any code, and while youtube might rename their javascript files, or functions from those files, they are unlikely to ever rename their favicon.
This worked for me... Its also my first post, hope it helps some one too.