tags:

views:

321

answers:

1

I'm trying to load a youtube video in a webpage. Not overly difficult, and works fine.

<object width="600" height="362"> 
<param name="movie" value="http://www.youtube.com/v/etc"&gt;&lt;/param&gt; 
<param name="allowFullScreen" value="true"></param> 
<embed src="http://www.youtube.com/v/etc" type="application/x-shockwave-flash"
width="600" height="362" 
allowfullscreen="true">
</embed> 
</object> 

There is no problem if Flash is not present or disabled - it just shows whats in the middle of the embed.

But if youtube is blocked (at the firewall, or /etc/hosts pointing to the wrong IP), I just get nothing.

Anyone know of a way to display something in this case? eg an image (or any html for that matter).

[edit] I guess I should add: I dont have access to Flash, so I can't make a new SWF and embed it (sorry, George, the idea looks good, but I dont have the tools).

I need something which I can do in HTML and Javascript, on the client. Ta.

Thanks

A: 

Can you try to load the video and listen for an HTTPStatus event, a security error, anything that might let you know the video won't work, if so display alternate content ?

var ytLoader:Loader = new Loader();
ytLoader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, ytHTTPStatus);
ytLoader.load(new URLRequest('http://www.youtube.com/v/kDKiQfBs9lo'));

function ytHTTPStatus(event:HTTPStatusEvent):void {
    if(event.status != 200) trace('display alternate content');
}

If you can only access stuff through Javascript, I suggest having a look at the YouTubePlayer API

I'm guessing that if there is any problem with displaying a video, that should be visible if you try to access any data from the video like:

HTH

George Profenza
thanks- I'll give that a go.... (and mark the question answered after that)
Nic Wise
Still testing it, but will give you the points :)
Nic Wise
thanks, HTH though :)
George Profenza
In the end, not so much. I dont have access to any ActionScript - only javascript/html. The swfobject has a callback, but it says ok even if I point youtube.com to 127.0.0.1.....
Nic Wise
can you access any data through the JS API ? links provided above
George Profenza