开发者

How to show static image when a site hosting Flash is blocked

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.youtu开发者_运维技巧be.com/v/etc"></param> 
<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


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:

  • video information( duration, video url, video embed code )
  • not much change going on through the onStateChange event.

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜