我使用 jwplayer.version = '5.10.2295' 和浏览器 chrome 25。
我的代码:
jwplayer('container').setup({
file: 'path...',
width: '300px',
height: '100px',
autostart: true,
modes: [
{ type: 'html5' },
{ type: 'flash', src: 'path...' }
]
});
加载页面后,我的资源(mp4 视频文件)开始正确显示 - 没问题。 但对简单的 jwplayer JS API 方法没有反应,例如 jwplayer().stop()。有些控件不可用(播放、顶部、搜索),但“全屏模式”按钮和音量按钮一样有效。
最有趣的是,js api 和控制按钮在视频开始播放后几秒钟可用(如果浏览器缓存被清除),然后没有响应交互。但有些方法始终正确工作(例如 jwplayer().setFullscreen())。
附:我看到相关question但答案对我来说还不够深入。
最佳答案
我找到了解决方案。
我的视频文件在路径中没有指定的扩展名(我有“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...' }
]
});
这就是解决方案。
关于javascript - JW Player javaScript API 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13800386/