我正在使用网站中的 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/