Search code examples
apache-flexyoutube

Detecting if YouTube is blocked by company / ISP


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'.


Solution

  • I like lacker's solution, but yes, it creates a race condition. This will work and won't create a race contition:

    var image = new Image();
    image.onload = function(){
    // The user can access youtube
    };
    image.onerror = function(){
    // The user can't access youtube
    };
    image.src = "http://youtube.com/favicon.ico";