如何使用 JW 播放器在所有浏览器/设备中播放视频

How to play video in all browser/device using JW Player?

本文关键字:视频 播放 浏览器 JW 何使用 播放器      更新时间:2023-09-26

我在我的项目中使用 JW 播放器,其中包含许多格式的视频:MP4、FLV、OGV、WMV

我阅读了每个浏览器支持的不同格式的文档。所以,现在我使用MP4(Chrome,Safari),FLV(IE,7,8,9)和WEBM(Mozilla)。

jwplayer('container').setup({
                height: 309,
                width: 549,
                levels: [
                    { file: "video.mp4" },
                    { file: "video.webm" },
                    { file: "video.flv" }
                ], 
                'modes': [
                    {type: 'html5'},
                    {type: 'flash', src: "jwplayer.flash.swf"},
                    {type: 'download'}
                ]
});

我的问题是,如果这段代码正在执行:检查浏览器是否支持HTML5或FLASH ->取决于浏览器自动复制MP4(Chrome - Safari)或FLV(IE)或WEBM(Mozilla)。

因为,特别是在Mozilla中,我第一次收到消息:"加载媒体时出错:无法播放文件".然后,当我单击2或1次时,播放视频。

也许这发生在文件的顺序上?


更新

我更改了我的 mime.conf 设置和 .htaccess,添加了以下行:

注意:我在我的Codeigniter项目中使用Drupal的.htaccess

.htaccess:

#
# Apache/PHP/Drupal settings:
#
#For disable gzip
SetEnvIfNoCase Request_URI '.(og[gv]|mp4|m4v|webm)$ no-gzip dont-vary
#For add mime types
AddType video/ogg  .ogv
AddType video/mp4  .mp4
AddType video/webm .webm
[...]

哑剧

#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
#AddType application/x-gzip .gz .tgz
AddType application/x-bzip2 .bz2
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm

我禁用了gzip压缩,但问题仍然存在。只有我的应用程序进入脸书的iframe无法通过视频网络。MP4工作正常。


更新 2

这里的问题是Twitter引导程序。我将其用于显示模态。在显示视频的模态之前,我将cookie保存在浏览器中。

当我将视频放入模态时,视频无法播放。当我点击2次视频时,这个视频播放。仅在 Mozilla Firefox 中;铬,IE 7-8-9工作正常。

当我把视频放出模态时。这在所有浏览器中正常播放。

对不起我的英语。

由于通过查看您的链接,我已经能够确定您现在使用的是 JW6,而不是 JW5,您应该使用不同的代码。

此代码:

jwplayer('container').setup({
                height: 309,
                width: 549,
                levels: [
                    { file: "video.mp4" },
                    { file: "video.webm" },
                    { file: "video.flv" }
                ], 
                'modes': [
                    {type: 'html5'},
                    {type: 'flash', src: "jwplayer.flash.swf"},
                    {type: 'download'}
                ]
});

应该看起来像这样,例如:

jwplayer('container').setup({
                height: 309,
                width: 549,
                playlist: [{
                sources: [
                    { file: "video.mp4" },
                    { file: "video.webm" },
                    { file: "video.flv" }
                ]
                }]
});

这是因为在JW6模式中被删除,HTML5已经是主要模式,"级别"被"源"取代。

这是一个迁移文档 - http://www.longtailvideo.com/support/jw-player/28834/migrating-from-jw5-to-jw6

jw6中使用多个文件的示例在这里 - http://www.longtailvideo.com/support/jw-player/29251/mp4-and-webm-formats