Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
93
rated 0 times [  100] [ 7]  / answers: 1 / hits: 71482  / 8 Years ago, mon, may 9, 2016, 12:00:00

I know that i can create an audio object like this:



var audio = new Audio(test.wav);


And i know how i can play the 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 setting for volume. Is it possible to change the volume in the audio object?






HINT



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);
}
}




More From » audio

 Answers
252

It's not a function, it's a property called volume.



audio.volume = 0.2;


HTMLMediaElement volume MDN


[#62253] Friday, May 6, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marcos

Total Points: 331
Total Questions: 106
Total Answers: 104

Location: Gabon
Member since Sat, Jul 25, 2020
4 Years ago
marcos questions
Thu, Feb 24, 22, 00:00, 2 Years ago
Sat, Apr 17, 21, 00:00, 3 Years ago
Mon, Feb 1, 21, 00:00, 3 Years ago
Tue, Jan 26, 21, 00:00, 3 Years ago
Wed, Jan 6, 21, 00:00, 3 Years ago
;