How to set volume on audio.play()

时间:2017-04-10 01:39:59

标签: javascript audio

Nothing fancy here, I just want the audio to play at a desired volume level.

var audio = new Audio('mysound.mp3');
audio.play();

I assume there are parameters I can pass into audio.play, but I've had a hard time finding a good reference.

Thanks!

2 个答案:

答案 0 :(得分:2)

You set volume like so

audio.volume = 0.75; // 75%

答案 1 :(得分:0)

You can simply just do this:

audio.sound = .5

Before you call audio.play ()