在IE中播放背景音乐,可以用bgsound
简单的语句如下:
<bgsound src="3.mp3" loop="-1" id="soundctl">
其中src指的是设置或获取要播放的声音的 URL.(Sets or retrieves the URL of a sound to play)
loop指的是设置或获取声音或视频剪辑在激活时的循环播放次数 值为-1时指的是无限次播放.值为0时播放一次.值为其它数值时播放的次数为设置的数值.它的缺省值为1次.
id为获取标识 对象的字符串.
如果控制播放能否停止,如下语句:
if(document.getElementById("soundctl").src!=""){
document.getElementById("soundctl").src=""
}else{
document.getElementById("soundctl").src="3.mp3"
}
bgsound在firefox中没有作用,所以要用到embed,简单语句如下:
<embed name="onlineCallSound"
src="images/msg.mp3"
loop=false
autostart=true
type=audio/mpeg mastersound
hidden=true
width=0
height=0>
</embed>
我用的是Firefox/3.0.5,并且装了iTunesSetup插件,很奇怪的是设置了hidden=true后,背景音乐不响,所以只能将width=0 ,height=0,把loop设为true的话,背景音乐只能响一次,所以我设置了playcount="9999",所以写出的语句如下:
<embed src="<%=request.getContextPath()%>/Video/3.wma"
width="0"
height="0"
playcount="9999"
autostart="true"
id="soundctl">
</embed>
控制播放的js如下:
dosound.src = $("#soundctl").get()[0].src;
dosound.soundctl = $("#soundctl").get()[0];
function dosound(){
with(dosound){
if(src!=""){
soundctl.pause();
src="";
}else{
src = getCurrent()+"/Video/3.wma";
soundctl.play();
}
}
}
可以在IE,FIREFOX中实现背景音乐的播放,但是FIREFOX中却不能实现音乐的控制!
简单的语句如下:
<bgsound src="3.mp3" loop="-1" id="soundctl">
其中src指的是设置或获取要播放的声音的 URL.(Sets or retrieves the URL of a sound to play)
loop指的是设置或获取声音或视频剪辑在激活时的循环播放次数 值为-1时指的是无限次播放.值为0时播放一次.值为其它数值时播放的次数为设置的数值.它的缺省值为1次.
id为获取标识 对象的字符串.
如果控制播放能否停止,如下语句:
if(document.getElementById("soundctl").src!=""){
document.getElementById("soundctl").src=""
}else{
document.getElementById("soundctl").src="3.mp3"
}
bgsound在firefox中没有作用,所以要用到embed,简单语句如下:
<embed name="onlineCallSound"
src="images/msg.mp3"
loop=false
autostart=true
type=audio/mpeg mastersound
hidden=true
width=0
height=0>
</embed>
我用的是Firefox/3.0.5,并且装了iTunesSetup插件,很奇怪的是设置了hidden=true后,背景音乐不响,所以只能将width=0 ,height=0,把loop设为true的话,背景音乐只能响一次,所以我设置了playcount="9999",所以写出的语句如下:
<embed src="<%=request.getContextPath()%>/Video/3.wma"
width="0"
height="0"
playcount="9999"
autostart="true"
id="soundctl">
</embed>
控制播放的js如下:
dosound.src = $("#soundctl").get()[0].src;
dosound.soundctl = $("#soundctl").get()[0];
function dosound(){
with(dosound){
if(src!=""){
soundctl.pause();
src="";
}else{
src = getCurrent()+"/Video/3.wma";
soundctl.play();
}
}
}
可以在IE,FIREFOX中实现背景音乐的播放,但是FIREFOX中却不能实现音乐的控制!