JW播放器javaScript API不工作
我使用jwplayer.version='5.10.2295'和浏览器chrome25 我的代码:JW播放器javaScript API不工作,javascript,api,google-chrome,jwplayer,Javascript,Api,Google Chrome,Jwplayer,我使用jwplayer.version='5.10.2295'和浏览器chrome25 我的代码: jwplayer('container').setup({ file: 'path...', width: '300px', height: '100px', autostart: true, modes: [ { type: 'html5' }, { type: 'flash', src: 'path...' } ]
jwplayer('container').setup({
file: 'path...',
width: '300px',
height: '100px',
autostart: true,
modes: [
{ type: 'html5' },
{ type: 'flash', src: 'path...' }
]
});
当页面加载时,我的资源(mp4视频文件)开始正确显示-正常。
但是对于简单的jwplayer JS API方法,例如jwplayer().stop(),没有任何反应。有些控件不可用(播放、播放、搜索),但“至全屏模式”按钮与音量按钮一样工作
最有趣的是,JSAPI和控制按钮在视频开始播放后的几秒钟内可用(如果浏览器缓存被清除),然后没有交互响应。但有些方法始终正确工作(例如jwplayer().setFullscreen()
p、 我看到了相关的问题,但答案对我来说并不深刻。我找到了解决办法
我的视频文件在路径中没有指定的扩展名(我使用的是'path/to/file'而不是'path/to/file.mp4'),这一事实在jwPlayer的深度中破坏了一些东西。我们需要指定使用的文件类型:
jwplayer('container').setup({
file: 'path/to/file-with-no-extension',
width: '300px',
height: '100px',
autostart: true,
type: 'video', //helps jwplayer to determine how to handle our resource with no extension
modes: [
{ type: 'html5' },
{ type: 'flash', src: 'path...' }
]
});
这就是解决方案。从
将这些文件放入特定目录:-
- app/assets/jwplayer/jwplayer.flash.swf
- 供应商/assets/javascripts/jwplayer.js
- 供应商/assets/javascripts/jwplayer.html5.js
//= require jwplayer
//= require jwplayer.html5
在播放视频的页面上,添加以下行
<script type="text/javascript">jwplayer.key="YOUR_JWPLAYER_KEY";</script>
<div id="video">Loading the player ...</div>
<script type="text/javascript">
jwplayer("video").setup({
flashplayer: "<%=asset_path('jwplayer.flash.swf')%>",
file: "<%= file_path %>",
height: 360,
width: 640,
analytics: {
enabled: false,
cookies: false
}
});
jwplayer.key=“您的jwplayer\u key”;
正在加载播放器。。。
jwplayer(“视频”)。设置({
flashplayer:“,
文件:“”,
身高:360,
宽度:640,
分析:{
启用:false,
曲奇:错
}
});
从那里您可以在注册时获得免费的自托管密钥,从获取许可证密钥部分