I embedded a background audio into my website which autoplays on visit.
The source of the audio is a online stream hotlink.
<audio autoplay> <source src="http://lel.com/link/to/stream.m3u"> </audio>
I already managed to do that and it's working well.
Now I want to turn down the volume of the stream because the audio should just stay in the background and entertain the visitors instead of giving them ear cancer due to loudness.
I already searched the forums but I always found solutions for turning the volume of a video.
I also searched for the parameters of the audio tag but there seems no volume parameter for the audio tag.
Don't worry about legalities. The stream I use for the website has no copyright and I am permitted to use it on my website.
The <audio> tag is used to embed sound content in a document, such as music or other audio streams.
<audio> can be styled as any other html element. To increase the width just use the css property width .
HTML Audio - How It WorksThe controls attribute adds audio controls, like play, pause, and volume. The <source> element allows you to specify alternative audio files which the browser may choose from. The browser will use the first recognized format.
Theres no volume attribute supported by browsers so you must set the volume property in JavaScript
<audio autoplay id="myaudio"> <source src="http://lel.com/link/to/stream.m3u"> </audio> <script> var audio = document.getElementById("myaudio"); audio.volume = 0.2; </script>
See http://jsfiddle.net/sjmcpherso/6r1emoxq/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With