javascript VideoJs 与 Firefox 的闪退问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17644444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 09:03:41  来源:igfitidea点击:

Issue with the flash fallback of VideoJs with Firefox

javascripthtmlflashvideovideo.js

提问by EtienneKingdom

I have try to add videoJs to my site to play MP4 files, all works perfectly in Chrome but when I go to Firefox (which doesn't support MP4 files) the flash player stay on a black screen and buttons do nothing.

我尝试将 videoJs 添加到我的网站以播放 MP4 文件,一切都在 Chrome 中完美运行,但是当我转到 Firefox(不支持 MP4 文件)时,Flash 播放器停留在黑屏上,按钮什么也不做。

Simple question: why? I don't understand, websites like vine.co or instagram use videoJs with no issue but for me this is not the case.

简单的问题:为什么?我不明白,像 vine.co 或 instagram 这样的网站使用 videoJs 没有问题,但对我来说情况并非如此。

So I tried to change the tech order, now Flash always try to read the video but even on chrome nothing append.

所以我试图改变技术顺序,现在 Flash 总是尝试阅读视频,但即使在 chrome 上也没有附加任何内容。

This is my test code:

这是我的测试代码:

<!DOCTYPE html>
<html>
<head>
    <title>test</title>

    <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>
    <script src="http://vjs.zencdn.net/4.0/video.js"></script>
    <script>
      videojs.options.flash.swf = "video-js.swf"
    </script>
</head>
<body>
    <video id="video" src="http://domain.com/flash/video.mp4" control></video>
    <script type="text/javascript">
        jQuery(function() {
            var player = videojs('video', {"controls": true, "autoplay": false, "preload": "auto", "techOrder": ["flash", "html5"]});
            console.log(player);
        });
    </script>
</body>
</html>

All the files (the swf player, the MP4 video, and the html file) are in the same folder named 'flash'.

所有文件(swf 播放器、MP4 视频和 html 文件)都位于名为“flash”的同一文件夹中。

Can you help me?

你能帮助我吗?

回答by zungaphobia

A few things to try here:

在这里尝试一些事情:

  1. Make sure you're loading the video-js css file.
  2. Add the "video-js" and skin classes to your video object as described here (also, it is "controls", not "control"): https://github.com/videojs/video.js/blob/0020ba15b9ae2b60e51d4d8d2751ffa31d18694d/docs/guides/setup.md
  3. If you're loading video js from the CDN, you don't need to set the flash.swf option. That may be causing an issue as well.
  1. 确保您正在加载 video-js css 文件。
  2. 将“video-js”和皮肤类添加到您的视频对象中,如下所述(同样,它是“控件”,而不是“控件”):https: //github.com/videojs/video.js/blob/0020ba15b9ae2b60e51d4d8d2751ffa31d18694d/文档/指南/setup.md
  3. 如果是从 CDN 加载视频 js,则不需要设置 flash.swf 选项。这也可能导致问题。

You shouldn't need to set the techOrder to get Firefox to behave, and you definitely don't need a corresponding video file for each type of "Tech". Flash will play the fallback in mp4 as long as it's above version 9 or so.

您不需要设置 techOrder 来让 Firefox 运行,而且您绝对不需要为每种类型的“技术”提供相应的视频文件。Flash 将在 mp4 中播放回退,只要它高于版本 9 左右。

I did run into an issue on Firefox where the Flash fallback would play the video but the video would be blank (audio would play) when I included a "ready" event. I was able to get around this by firing a blur event on the $(this) object. That may be helpful to you if you need to use ready.

我确实在 Firefox 上遇到了一个问题,即 Flash 后备将播放视频,但当我包含“就绪”事件时,视频将是空白的(将播放音频)。我能够通过在 $(this) 对象上触发模糊事件来解决这个问题。如果您需要使用 ready,这可能对您有所帮助。

回答by Matthias Hermsdorf

You need a flv Version of your Video when you want to deliver it through flash. It could be usefull to offer another webm Version of your Video. This should bei played in Firefox and Chrome.

当您想通过 Flash 传送视频时,您需要一个 flv 版本的视频。提供另一个 webm 版本的视频可能会很有用。这应该在 Firefox 和 Chrome 中播放。

For every Tech you need the correspondenting videofile.

对于每个技术,您都需要相应的视频文件。