虽然在 html5 模式下播放 mp4 文件效果很好,但播放器在 flash 模式下既不能播放 flv 文件,也不能在 flash 模式下播放 mp4 文件。在 Chrome (44.0.2403.157) 和 Firefox (40.0.3) 中,它会无限期地加载。
更奇怪的是,来自 jwplayer 仪表板 ( https://dashboard.jwplayer.com/#/players/basic_setup ) 的播放器在使用以下调用从控制台加载 flv 文件时设法播放它们:
jwplayer(document.querySelector('.jwplayer')).load([{ file:'http://www.sample-videos.com/video/flv/720/big_buck_bunny_720p_1mb.flv' }]);
这是一个展示该问题的jsfiddle:
https://jsfiddle.net/kLdmj42d/(确保您指定了许可证密钥)
只需切换 mp4 和 flv 文件上的注释,以确保它确实适用于 mp4 文件。
HTML:
<div class="main">
<div id="player">
</div>
</div>
JS:
jwplayer.key = "";
jwplayer.defaults = {
aspectratio: "16:9",
autostart: false,
controls: true,
displaydescription: false,
displaytitle: true,
flashplayer: "//ssl.p.jwpcdn.com/player/v/7.0.3/jwplayer.flash.swf",
height: 260,
mute: false,
ph: 1,
//plugins: {"http://assets-jpcust.jwpsrv.com/player/6/6124956/ping.js": {"pixel": "http://content.jwplatform.com/ping.gif"}},
primary: "html5",
repeat: false,
stagevideo: false,
stretching: "uniform",
width: "100%"
};
jwplayer(document.getElementById('player')).setup({
file: 'http://www.sample-videos.com/video/flv/720/big_buck_bunny_720p_1mb.flv'
//file: 'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4'
});
我还在 JwPlayer 的网站上发布了这个问题:http: //support.jwplayer.com/customer/portal/questions/14332602-jwplayer-7-3-with-flash-18-not-playing-videos