我在网站上使用JW Player播放YouTube视频。我已经使用了嵌入代码。从我的本地diretory执行文件时,它在所有浏览器中都能正常工作。但是当从服务器执行文件时,它无法在谷歌浏览器中工作。以下是代码。
<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"/>
请帮助实现这一目标。提前谢谢。
答案 0 :(得分:3)
首先,我们应该让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,
});
这适用于所有浏览器。如果支持HTML5,jwplayer可以符合。
或以下强制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/