今天客户一个[url=http://www.chinab2c.net/content/9.html]B2C服装类网上商城系统[/url]需要在网站里播放背景音乐。bgsound是不行的,因为只有IE支持这个标签。关键是要跨浏览器。
考虑jquery,发现jplayer可以实现这个效果。试了一下,门槛还算OK。
如果 swfPath:"http://www.ipremoire.com/js/jquery"不设置swf目录路径。
IE FF 里面无法正常播放
考虑jquery,发现jplayer可以实现这个效果。试了一下,门槛还算OK。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery/jquery.jplayer.min.js"></script>
<div id="jquery_jplayer"></div>
<img id="jplayer" src="/images/music-play.png" width="44" height="41" style="float:right;"/>
<img id="jstop" style="display:none" src="/images/music-stop.png" width="44" height="41" style="float:right;"/>
$("#jplayer").click(function(){
$(this).hide();
$("#jstop").show();
$("#jquery_jplayer").jPlayer( "pause" );
});
$("#jstop").click(function(){
$(this).hide();
$("#jplayer").show();
$("#jquery_jplayer").jPlayer( "play" );
});
$(document).ready(function(){
$("#jquery_jplayer").jPlayer({
ready: function () {
this.element.jPlayer("setFile", "${music}", "").jPlayer("play");
},
volume: 50,
oggSupport: false,
preload: 'none',
swfPath:"http://www.i.com/js/jquery"
})
.jPlayer("onSoundComplete", function() {
this.element.jPlayer("play");
});
});
如果 swfPath:"http://www.ipremoire.com/js/jquery"不设置swf目录路径。
IE FF 里面无法正常播放