通过企业代理的后备解决方案嵌入 YouTube 视频

发布于 2024-12-20 10:53:24 字数 255 浏览 2 评论 0原文

我想知道你们中是否有人遇到过允许嵌入 YouTube 视频和后备解决方案的解决方案/功能,其中如果 YouTube 视频 - 并且仅是视频,则选择替代视频源! - 被阻止。

我们的一位企业客户可以通过代理服务器访问网络,该服务器会清除 YouTube 提供的 Flash 内容。更具体地说,从 ytimg.com 提供的任何内容都会被阻止。由于他们的网站上有大量的产品视频,他们发现客户可以在他们的网站上观看视频,而他们自己的员工却不能,这很烦人。

有什么建议吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寄人书 2024-12-27 10:53:24

您应该尝试向 youTube 中托管的内容发出 Ajax 请求,我会这样说:

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');
    }
  });
}

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');
    }
  });
}
唠甜嗑 2024-12-27 10:53:24

需要澄清的是,Youtube 的 Flash 播放器与其播放的 FLV 或 MP4 文件是不同的。虽然 Flash 播放器可能由 *.ytimg.com 提供服务,但流本身来自“oo.preferred.lga15s18.v2.lscache6.c.youtube.com”等主机。

如果您的客户阻止前者,那么您将无法使用 Youtube 来观看视频。我的方法是从一个页面启动您的视频,该页面具有某种自动化功能,可以识别您客户的 IP 地址范围并加载您自己的 jwplayerflowplayer 或类似的东西。

虽然您可以使用 ajax 调用之类的方法在浏览器端执行此操作,但您仍然面临着过于保守的企业 IT 禁用 JavaScript 的风险。 (我已经看到它发生了。这并不漂亮。)将“智能”放在您的服务器上可以让您掌控一切,当然这意味着您需要提前知道限制是什么,以便您可以进行调整。

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.

jJeQQOZ5 2024-12-27 10:53:24

构建页面时,您可以测试与 ytimg.com 的工作连接,并相应地更新用于显示的 iframe 源...

<iframe src="<?php

//Use a dummy (but valid) ytimg.com url to check for ytimg availability...
$h = get_headers('http://s.ytimg.com/yt/swfbin/watch_as3-vflZzp2iQ.swf');

//If ytimg.com isn't available...
if (stristr($h[0], '200') == FALSE)
{ ?>

    <!--Alt URL-->

<?php

//Otherwise, if ytimg.com is available...
} else { ?>

    <!--YouTube URL-->

<?php } ?> "></iframe>

或者,您可以礼貌地建议您的客户不要那么强硬并允许员工在工作时偶尔使用 YouTube 休息一下。

编辑开玩笑吧,我是个白痴。使用上面 camilo_u 的建议。

When building the page, you could test for a working connection to ytimg.com, and update the source of the iframe you're using for display accordingly...

<iframe src="<?php

//Use a dummy (but valid) ytimg.com url to check for ytimg availability...
$h = get_headers('http://s.ytimg.com/yt/swfbin/watch_as3-vflZzp2iQ.swf');

//If ytimg.com isn't available...
if (stristr($h[0], '200') == FALSE)
{ ?>

    <!--Alt URL-->

<?php

//Otherwise, if ytimg.com is available...
} else { ?>

    <!--YouTube URL-->

<?php } ?> "></iframe>

Alternatively, you could politely suggest that your client not be such a hard-ass and allow their employees the occasional YouTube break at work.

EDIT Just kidding, I'm an idiot. Use camilo_u's suggestion above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文