HTML5 视频什么时候应该回退到 Flash 播放器?

发布于 2024-09-10 00:05:03 字数 1130 浏览 4 评论 0原文

我正在致力于为 HTML5 视频播放器实现后备机制。我有办法用 swfobject Flash 播放器替换它,但我应该如何检测是否出现任何问题?

换句话说,如果我们使用以下可以抛出的错误事件列表,哪一个应该触发 Flash 播放器替换?或者如果抛出任何错误,我们应该简单地进行替换吗?

另外,onError 处理程序应该在哪里调用?我正在考虑 video 标签,但想确认一下。非常感谢您的指导。谢谢。

   function failed(e) {
     // video playback failed - show a message saying why
     switch (e.target.error.code) {
       case e.target.error.MEDIA_ERR_ABORTED:
         alert('You aborted the video playback.');
         break;
       case e.target.error.MEDIA_ERR_NETWORK:
         alert('A network error caused the video download to fail part-way.');
         break;
       case e.target.error.MEDIA_ERR_DECODE:
         alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.');
         break;
       case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
         alert('The video could not be loaded, either because the server or network failed or because the format is not supported.');
         break;
       default:
         alert('An unknown error occurred.');
         break;
     }
   }

I'm working on implementing a fallback mechanism for the HTML5 video player. I've got a way to replace it with the swfobject Flash player, but how should I detect if any issues have developed?

In other words, if we use the following list of error events that can be thrown, which one should trigger the Flash player replacement? Or should we simply do a replacement if any error is thrown?

Also, where should the onError handler be called? I'm thinking on the video tag, but want to make sure. Your guidance is much appreciated. Thanks.

   function failed(e) {
     // video playback failed - show a message saying why
     switch (e.target.error.code) {
       case e.target.error.MEDIA_ERR_ABORTED:
         alert('You aborted the video playback.');
         break;
       case e.target.error.MEDIA_ERR_NETWORK:
         alert('A network error caused the video download to fail part-way.');
         break;
       case e.target.error.MEDIA_ERR_DECODE:
         alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.');
         break;
       case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
         alert('The video could not be loaded, either because the server or network failed or because the format is not supported.');
         break;
       default:
         alert('An unknown error occurred.');
         break;
     }
   }

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

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

发布评论

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

评论(1

诗酒趁年少 2024-09-17 00:05:03

这里的问题是,许多问题无法通过切换到 Flash 来解决。事实上,只有当您在 IE、FF 和 Opera 中播放 MP4 时,以及在所有浏览器中播放 FLV 时,切换到 Flash 才能让您真正受益。 (这显然会根据 webm / Theora 的原生 Flash 支持而发生变化。)

因此,我们对 HTML5 的 JW Player 进行了以下操作:

此解决方案并非万无一失,但它可以让您完成 90% 以上的工作。

最佳,

扎克

开发者,长尾视频

The trouble here is that many issues can't be fixed by switching to Flash. In fact, the only time you're really benefited by switching to Flash is in IE, FF, and Opera when you've got an MP4 to play, and in all browsers when you've got an FLV. (This is obviously subject to change based on native Flash support for webm / Theora.)

For this reason, we've done the following for the JW Player for HTML5:

This solution isn't foolproof, but it gets you 90%+ of the way there.

Best,

Zach

Developer, LongTail Video

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