php - JW Player 无法在 Chrome 中运行

标签 php embed jwplayer

我正在使用网站中的 JW Player 播放 youtube 视频。我为此使用了嵌入代码。从我的本地目录执行文件时,它在所有浏览器中都能正常工作。但是从服务器执行文件时它在谷歌浏览器中不起作用。下面是代码。

<embed id="ply" height="384" width="430" flashvars="autostart=true&repeat=always&file=http:/www.youtube.com/watch?v=cNBFihPwThM&screencolor=000000&backcolor=000000&frontcolor=ffffff&skin=http://www.creatingafamily.org/modules/mod_jwmedia/skins/snel.swf" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" quality="high" bgcolor="#000000" name="ply" style="" src="http://www.creatingafamily.org/modules/mod_jwmedia/player.swf" type="application/x-shockwave-flash"/>

请帮助实现这一目标。提前致谢。

最佳答案

首先,我们应该让jwplayer的javascript来构建html代码。

用js初始化jwplayer,在html中使用HTML5视频是这样的:

<center>            
    <video controls="controls" id="container" poster="http://www.example.com/yourvideothumbs/videothumb.jpg"  width="693" height="388">
            <source src="http://www.example.com/videos/jourvideo.mp4" type="video/mp4" />
    </video>                        
</center>

Javascript:

if(navigator.userAgent.toLowerCase().match(/(android)/) || navigator.userAgent.toLowerCase().match(/(chrom)/) ){
    //wee must force flash video player in chrome, because mp4 video files is not supported yet in chrome's HTML5 video implementation.
    modes = [{type: 'flash', src:  '[JWPLAYERBASEDIR]/swf/player.swf'}];
}else{
    modes = [ {type: 'html5'},{type: 'flash', src:  '[JWPLAYERBASEDIR]swf/player.swf'}];
}

jwplayer("container").setup({                   
    'modes':modes,      
}); 

这在所有浏览器中都有效。 jwplayer 可以符合是否支持 HTML5。

或以下带有强制 HTML4 实现的内容:

<div id="container"></div>
<script type="text/javascript">
    jwplayer("container").setup({
       modes = [{type: 'flash', src:  '[JWPLAYERBASEDIR]/swf/player.swf'}], //force flashplayer for video
       image: "yourvideothumbs/videothumb.jpg", //poster image
       file: "videos/jourvideo.mp4",  //video file 
       height: "693", //set height in px
       width: "388" //set width in px
   });

在设置中你可以设置skin, controls, autostart任何你想要的: http://www.longtailvideo.com/support/jw-player/28839/embedding-the-player/

关于php - JW Player 无法在 Chrome 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15740680/

相关文章:

PHP表单与MYSQL仅发布我输入的内容。而不是搜索结果

php - 删除文件名中除文件扩展名前的点之外的所有点

php - 通过 cron 运行的 php 文件的参数

php - 即使使用 jquery 添加了新行,我如何在 ajax 的数据表中添加(数字总和)

iframe - 嵌入网站的一部分

html - 伪流式传输 MP4 文件

javascript - 我如何包含一个具有自动高度的子 div -- Jwplayer

iframe - 如何在 youtube Iframe 上禁用全屏?

jupyter-notebook - 如何将 plotly 可视化嵌入到谷歌幻灯片中?

javascript - 如何使用 javascript 命令在 jw player 中获取源 url