Dshiz
Dshiz

Reputation: 3331

How to set volume on audio.play()

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!

Upvotes: 0

Views: 4673

Answers (2)

RyanM
RyanM

Reputation: 761

You can simply just do this:

audio.sound = .5

Before you call audio.play ()

Upvotes: -1

AlexanderB
AlexanderB

Reputation: 959

You set volume like so

audio.volume = 0.75; // 75%

Upvotes: 6

Related Questions