Javascript JW Player 加载媒体时出错:无法播放文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30719487/
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-08-23 05:38:53  来源:igfitidea点击:

JW Player Error loading media: File could not be played

javascripthtmljwplayerjwplayer6

提问by Marcus Rommel

We ran into a very strange problem with JW Player and really don't know an approach to solve it.

我们在使用 JW Player 时遇到了一个非常奇怪的问题,并且真的不知道解决它的方法。

JW Player shows the error:

JW Player 显示错误:

Error loading media: File could not be played

加载媒体时出错:无法播放文件

sporadically across all browsers and platforms (sometimes it shows up and sometimes not). It took me over 30 reloads to get it and some of my colleagues got it with their first try. It's behavior is very inconsistent and kind of random.

偶尔会出现在所有浏览器和平台上(有时显示有时不显示)。我花了 30 多次重装才得到它,我的一些同事在第一次尝试时就得到了它。它的行为非常不一致并且有点随机。

We're using FirstSpirit as CMS on an Apache Tomcat instance running on Windows server. The problem occurred on Chrome, IE and Firefox across all versions.

我们在 Windows 服务器上运行的 Apache Tomcat 实例上使用 FirstSpirit 作为 CMS。该问题出现在所有版本的 Chrome、IE 和 Firefox 上。

The MIME types of all videos are correct as their codecs are. If supported, JW Player is running in HTML5 mode. We use Flash only for older browsers (IE8 groan).

所有视频的 MIME 类型与其编解码器一样正确。如果支持,JW Player 将在 HTML5 模式下运行。我们仅将 Flash 用于较旧的浏览器(IE8 groan)。

I would appreciate any help. Thanks!

我将不胜感激任何帮助。谢谢!

Marcus

马库斯



UPDATE: Example page with video box on the right side. Example page with video

更新:右侧带有视频框的示例页面。带视频的示例页面

UPDATE: We updated the version as Ethan from JW Player suggested, but it's still not working properly.

更新:我们按照 JW Player 的 Ethan 建议更新了版本,但它仍然无法正常工作。

回答by Svetoslav Petrov

I would suggest to encode the video in .mp4 and .ogg. (MP4 is supported in Safari and IE9, Ogg in Firefox, Chrome and Opera and as you mentioned IE6-8 uses flash only). Thus your video element will look something like:

我建议将视频编码为 .mp4 和 .ogg。(Safari 和 IE9 支持 MP4,Firefox、Chrome 和 Opera 支持 Ogg,正如您提到的 IE6-8 仅使用 Flash)。因此,您的视频元素将类似于:

<video width="300" controls>
  <source src="my_video.ogg" type="video/ogg">
  <source src="my_video.mp4" type="video/mp4">
  Your browser does not support HTML5 video.
</video>

This will ensure that the video will be played if the browser support HTML5. I hope this helps

如果浏览器支持 HTML5,这将确保视频将被播放。我希望这有帮助