本文介绍了如何设置音频对象的音量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我可以像这样创建一个音频对象:
I know that i can create an audio object like this:
var audio = new Audio("test.wav");
我知道如何播放音频:
audio.play();
我使用以下 for
循环输出所有函数来自 audio
:
I used the following for
loop to output all functions from audio
:
var myAudioObject = new Audio();
for (var key in myAudioObject)
{
if (typeof myAudioObject[key] === "function")
{
console.log(key);
}
}
但是没有设置音量。是否可以更改音频对象的音量?
But there is no setting for volume. Is it possible to change the volume in the audio object?
提示
这是我的错。如果我在我的for循环中用 number
替换 function
,那么我找到了卷。
It was my fault. If i replace function
in my for loop with number
then i find volume.
var myAudioObject = new Audio();
for (var key in myAudioObject)
{
if (typeof myAudioObject[key] === "number")
{
console.log(key);
}
}
推荐答案
这是不是函数,它是一个名为 volume
的属性。
It's not a function, it's a property called volume
.
audio.volume = 0.2;
这篇关于如何设置音频对象的音量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!