如何在 JWPlayer 中强制 HTML5 和禁用 Flash

How to force HTML5 and disable Flash in JWPlayer

这是我的代码,在播放视频时应该使用 HTML5 播放器。

<html>
<head><script type="text/javascript" src="http://content.jwplatform.com/libraries/asdetr.js"></script></head>

<body>

<div id="myElement">Loading the player...</div>

<script type="text/javascript">

var playerInstance = jwplayer("myElement");
playerInstance.setup({
    file: "http://content.jwplatform.com/videos/trytry-789.mp4",
    image: "http://content.jwplatform.com/thumbs/dfg569-676.jpg",
    width: 640,
    height: 360,
    modes: [
            { type: "html5",

            config: {
              file: "http://content.jwplatform.com/videos/trytry-789.mp4"
                    }
            }
           ]
});
</script>
</body>
</html>

请建议我使用 HTML5 播放器的好方法。如果我做错了什么,请纠正我。

好像可以,我给你创造了这个fiddle:

https://jsfiddle.net/rdgfuentes/gwa5f438/

可能导致问题的原因之一是您从外部站点 (http://content.jwplatform.com/libraries/asdetr.js) 中包含 jwplayer,该站点目前正在返回 404。我将其更改为 http://content.jwplatform.com/libraries/XeGdlzmk.js 并暂时修复了它;但这不是最终的解决方案。

有两种在您的站点中实现 jwplayer 的方法,具体取决于您从何处加载库:

  • 云托管播放器:来自 jwplayer 服务器。
  • 自托管:来自您的服务器。

我一直采用自托管解决方案,这需要您下载软件包并将其所有文件包含在您的服务器上。

在这里您可以找到更多相关信息。 http://support.jwplayer.com/customer/portal/articles/1772740-dashboard-faq#self-hosted-vs-cloud-hosted

改用此代码。您正在使用适用于 JW Player 5 且非常不推荐使用的模式块。下面的代码可以工作,因为 JW6 和 JW7 已经将主要渲染模式强制设置为 HTML5。

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://content.jwplatform.com/libraries/asdetr.js"></script>
</head>   
<body> 
<div id="myElement">Loading the player...</div>   
<script type="text/javascript">   
var playerInstance = jwplayer("myElement");
playerInstance.setup({
    file: "http://content.jwplatform.com/videos/trytry-789.mp4",
    image: "http://content.jwplatform.com/thumbs/dfg569-676.jpg",
    width: 640,
    height: 360,
    fallback: false
});
</script>
</body>

试试这个代码。对我有用。

<html>
<head><script type="text/javascript" src="http://content.jwplatform.com/libraries/asdetr.js"></script></head>
<body>
<div id="myElement">Loading the player...</div>

<video crossorigin="anonymous" poster="http://support.jwplayer.com/customer/portal/attachments/268150" controls="controls" width="640" height="272">
<source src="http://content.jwplatform.com/videos/C4lp6Dtd-640.mp4" type="video/mp4" />

</video>
</body>
</html>