Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed YouTube videos with fallback solution for corporate proxies

I am wondering whether any of you have ever come accross a solution/function that allows embedding YouTube videos with a fallback solution where an alternative video source is selected if YouTube videos - and the videos only! - are blocked.

One of our corporate clients have access to the web via a proxy server that weeds out flash content served form YouTube. More specifically anything served from ytimg.com is blocked. Since their website is quite heavy on product videos they find it annoying to boot that clients can watch videos on their site while their own staff can't.

Any suggestions?

like image 698
Tomm Avatar asked Dec 07 '11 21:12

Tomm


2 Answers

You should try to make an Ajax request to something hosted in youTube, i would say something like this:

function check_youtube() {
  $.ajax({
    type: 'GET',
    dataType: 'json',
    url: URL_ON_YOUTUBE,
    timeout: 5000,
    success: function(data, textStatus ){
       alert('Woot, Cat videos on the way!');
    },
    error: function(xhr, textStatus, errorThrown){
       alert('Ooops, You suck, proxy blocking your way');
    }
  });
}
like image 125
camilo_u Avatar answered Oct 22 '22 13:10

camilo_u


It should be clarified that Youtube's Flash player is a different thing than the FLV or MP4 file that it plays. While the Flash player may be served from *.ytimg.com, the streams themselves come from hosts like "o-o.preferred.lga15s18.v2.lscache6.c.youtube.com".

If your client is blocking the former, then you can't use Youtube to get at the videos. My approach would be to launch your videos from a page that has some sort of automation to recognize your client's IP address range and load up your own copy of jwplayer or flowplayer or somesuch.

While you could do this browser-side using something like an ajax call, you still run the risk of overly-conservative corporate IT disabling javascript. (I've seen it happen. It's not pretty.) Putting the "smarts" on your server leaves you in control, though of course it means you need to know ahead of time what the restrictions are, so that you can adjust for them.

like image 2
ghoti Avatar answered Oct 22 '22 13:10

ghoti