html声音(html声音文件)
华为云服务器特价优惠火热进行中! 2核2G2兆仅需 38 元;4核4G3兆仅需 79 元。购买时间越长越优惠!更多配置及优惠价格请咨询客服。
合作流程: |
本篇文章给大家谈谈html声音,以及html声音文件对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
微信号:cloud7591如需了解更多,欢迎添加客服微信咨询。
复制微信号
本文目录一览:
html为什么在浏览器里没有声音
???没懂你问题,如果是这html里有加入音频标签引入音频文件,打开浏览器的时候没有声音有两个原因:
1.有可能没处理自动播放音频操作。
2.一般现在的浏览器默认不允许自动播放音视频。

用html如何播放wav文件?
方法一:
object classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' 调用media player
方法二:
bgsound loop="false" autostart="false" id="bgss" src="XXX"
html5 的audio:
audio src="../temp.wav" controls="controls"wav/audio
用HTML5的audio标签,就要考虑浏览器对音频格式的支持情况,见下图:
如果要兼容所有现代浏览器,建议以如下方式同时引入mp3和ogg格式:
audio preload="auto"
source src="test.mp3" /
source src="test.ogg" /
/audio
HTML里面如何使超链接有声音
声音 embed src="文件名称" hidden=true autostart=false JS script language="Javascript function play() { document.embeds.play()} function stop() { document.embeds.stop()} /script 链接 a onmouseover="playnote()" onmouseout="stopnote()" href=“”/a
希望采纳
HTML5 怎么给网页加屏幕点击声音。
利用HTML5中的audio标签,播放声音,不过为了照顾IE 6-8,还是用上了bgsound。
兼容所有主流浏览器(非主流不在考虑之列了)
代码:
a href="#" class="fui-btn"播放/a
script
/*Play sound component*/
/*
* profile: JSON, {src:'chimes.wav',altSrc:'',loop:false}
*
* setSrc: Function, set the source of sound
* play: Function, play sound
*/
if (!FUI){
var FUI = {};
}
FUI.soundComponent=function(profile){
this.profile={
src:'', //音频文件地址
altSrc:'', //备选音频文件地址 (不同浏览器支持的音频格式不同,可见附表)
loop:false //是否循环播放,这个参数现在没有用上
};
if(profile) {
$.extend(this.profile,profile);
}
this.soundObj=null;
this.isIE = !-[1,];
/*这个方法是前辈大牛发明的,利用ie跟非ie中JScript处理数组最后一个逗号“,”的差异,
不过对于IE 9,这个办法就无效了,但此处正合我用,因为IE 9支持audio*/
this.init();
};
FUI.soundComponent.prototype={
init:function(){
this._setSrc();
},
_setSrc:function(){
if(this.soundObj){
if(this.isIE){
this.soundObj[0].src=this.profile.src;
}else{
this.soundObj[0].innerHTML='source src="'+this.profile.src+'" /
source src="'+this.profile.altSrc+'" /';
}
}else{
if(this.isIE){
this.soundObj=$
('bgsound volume="-10000" loop="1" src="'+this.profile.src+'"').appendTo('body');
//-10000是音量的最小值。先把音量关到最小,免得一加载就叮的一声,吓到人。
}else{
this.soundObj=$('audio preload="auto" autobuffer
source src="'+this.profile.src+'" /
source src="'+this.profile.altSrc+'" /
/audio').appendTo('body');
}
}
},
setSrc:function(src,altSrc){
this.profile.src=src;
if(typeof altSrc!='undefined'){
this.profile.altSrc=altSrc;
}
this._setSrc();
},
play:function(){
if(this.soundObj){
if(this.isIE){
this.soundObj[0].volume = 1;//把音量打开。
this.soundObj[0].src = this.profile.src;
}else{
this.soundObj[0].play();
}
}
}
};
var sd=new FUI.soundComponent({src:'ding.wav',altSrc:'ding.mp3'});
$('.fui-btn').bind('click',function(e){
sd.play();
});
/script
关于html声音和html声音文件的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
