Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 308
Simon_Weaver Avatar asked Nov 13 '08 01:11

Simon_Weaver


1 Answers

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";
like image 137
tiangolo Avatar answered Oct 21 '22 08:10

tiangolo