求JS控制bgsound的方法

JavaScript012

求JS控制bgsound的方法,第1张

地址可以通过修改它的src属性来改变,音量可以使用它的volume 来改变,它的范围为-10000到0。

举一下改变声音的例子吧。

<SCRIPT Language="VBScript">

Function btnUp_OnClick()

Dim iVolume

iVolume = document.all.oSound.volume + 500

If iVolume <0 Then

document.all.oSound.volume = iVolume

End If

End Function

Function btnDown_OnClick()

Dim iVolume

iVolume = document.all.oSound.volume - 500

If iVolume >-10000 Then

document.all.oSound.volume = iVolume

End If

End Function

Function btnSilence_OnClick()

document.all.oSound.volume = -10000

End Function

</SCRIPT>

<bgSound src="音乐地址" id="oSound"/>

<button name="btnUp">加大</button>

<button name="btnDown">减小</button>

<button name="btnSilence">静音</button>

---------------------------------------------

你定义了一个变量,但没有赋值,所以不行,你需要对它进行赋值,如:

Dim iVolume

iVolume = document.all.oSound.volume

这样才能进行比较。

<!DOCTYPE html>

<html>

<head> 

<meta charset="utf-8"> 

<title></title> 

</head>

<body>

<audio id="ado" src="http://aimusic.file.alimmdn.com/Music/%E7%8E%8B%E8%80%85%E8%8D%A3%E8%80%80+-+%E5%87%AF.mp3" controls="controls" autoplay="autoplay"></audio>

当前音量<input type="text" id="vol"/>

</body>

<script type="text/javascript">

var audio_ = document.getElementById('ado')

var vol_ = document.getElementById('vol')

vol_.value = audio_.volume

var iv = null

setTimeout(function(){

iv = setInterval(function(){

if( audio_.volume > 0.05 ){

audio_.volume = (audio_.volume - 0.05).toFixed(2)

}else{

audio_.volume = 0

clearInterval(iv)

}

vol_.value = audio_.volume

}, 1000)

}, 5000)

</script>

</html>

游戏js音效加载失败解决方法如下。

.

先检查一下电脑右下角的小喇叭图标,看音量是否调到了最小,或者静音了,如果有请调之。

2.

问题如果没有解决的话,在桌上面,我的电脑右键->管理->设备管理器,找到声音、视频和游戏控制器,双击展示,如果一旦下面有一项中出现了“黄色的感叹号”,那么就是声卡驱动出问题了,解决的方法,安装声卡驱动(去官方下载,或者有备份过驱动的恢复驱动,再或者简单一点的,下载个驱动精灵,让它寻找有问题的驱动更新一下就解决了)

3.

或者打开控制面板,找到声音和音频设备,双击打开