JW Player javaScript API 不工作 [英] JW Player javaScript API not working

查看:23
本文介绍了JW Player javaScript API 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 jwplayer.version = '5.10.2295' 和浏览器 chrome 25.

I use jwplayer.version = '5.10.2295' and browser 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() 等.并且某些控件不可用(播放、顶部、搜索),但全屏模式"按钮与音量按钮一样有效.

When page is loaded my resource (mp4 video file) starts to show correctrly - it is ok. But there is no reaction on simple jwplayer JS API methods, suche as jwplayer().stop(), for example. And some controls are not available (play, top, seek), but 'to full screen mode' button works as well as volume button.

而最有趣的是,js api 和控制按钮在视频开始播放后几秒钟可用(如果浏览器缓存被清除),然后交互没有响应.但是某些方法始终正确运行(例如 jwplayer().setFullscreen()).

And the most interesting is that js api and control buttons available for a few seconds after video start to play (if browser cache is cleared), and then no response for interaction. But some method works all the time correctly (jwplayer().setFullscreen() for example).

附言我看到了相关的问题 但答案对我来说还不够深刻.

p.s. I saw related question but the answer is not deep anough for me.

推荐答案

我找到了解决方案.

我的视频文件在路径中没有指定的扩展名(我有'path/to/file'而不是'path/to/file.mp4'),这个事实打破了jwPlayer深处的某些东西.我们需要指定我们操作的文件类型:

My video file have no specified extension in path (i have 'path/to/file' instead of 'path/to/file.mp4') and that fact brokes somethin in the depths of jwPlayer. We need to specify type of file we operate with:

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...' }
    ]
});

这就是解决方案.

这篇关于JW Player javaScript API 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆