0

I'm trying to do what I thought was a very simple thing but, having searched the web, it seems not.

I'm using a free audio player 'audiojs' in conjunction with HTML5 audio to play an audio track and that all works fine. However, what I want to do is to set the audio volume to a low level initially, leaving the users able to increase it if they want to using the normal player slider.

I expected there would be an attribute like

<audio volume="low"> or <audio volume="0.5">

but there doesn't seem to be one. If it has to be done with Javascript, I would want to use jQuery.

Can anyone help?

Perkin5
  • 373
  • 3
  • 21
  • possible duplicate of [How to set the loudness of HTML5 audio?](http://stackoverflow.com/questions/10075909/how-to-set-the-loudness-of-html5-audio) – Jordan Robinson Aug 23 '14 at 22:26
  • I read that but didn't fully understand it. I tried it but it didn't work so I probably got it wrong. I don't understand javascript but how would you code it in jQuery starting with `$('audio').something();`? – Perkin5 Aug 24 '14 at 11:00

1 Answers1

0

With a HTML5 element, you can set the volume in javascript in the following way:

document.getElementById('audio-control').volume = 0.2;

Where the id is the id attribute on the audio control.

Here's an example of this in action:

http://jsbin.com/cezutiyuroxi/1/edit?html,js,output

Jordan Robinson
  • 805
  • 9
  • 22