How to set the volume of an audio object?

I know that I can create a sound object like this:

var audio = new Audio("test.wav"); 

And I know how I can play audio:

 audio.play(); 

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 configuration for the volume. Can I change the volume of an audio object?


HINT

That was my fault. If I replaced the function in my for loop with number , then I will find the scope.

 var myAudioObject = new Audio(); for (var key in myAudioObject) { if (typeof myAudioObject[key] === "number") { console.log(key); } } 
+5
source share
1 answer

This is not a function, this property is called volume .

 audio.volume = 0.2; 

http://www.w3schools.com/tags/av_prop_volume.asp

+10
source

All Articles