How to add background audio to your website
Published on July 14, 2023
Published on Wealthy Affiliate — a platform for building real online businesses with modern training and AI.
https://www.youtube.com/watch?v=KgPzS2PuHQ0
here are the codes>
<audio id="audio-player" autoplay loop>
<source src="path/to/audio-file.mp3" type="audio/mpeg">
<!-- Add additional source elements for different audio formats -->
<!-- Example: <source src="path/to/audio-file.ogg" type="audio/ogg"> -->
Your browser does not support the audio element.
</audio>
Ready to put this into action?
Start your free journey today — no credit card required.
and for volume>
<script>
document.addEventListener('DOMContentLoaded', function() {
var audio = document.getElementById('audio-player');
audio.volume = 0.5; // Set the volume (0.0 to 1.0, where 0.0 is mute and 1.0 is maximum)
});
</script>
if you don't want the song to start over after its over use in place of the first code this >
<audio id="audio-player" autoplay>
<source src=path/to/audio-file.mp3"; type="audio/mpeg">
<!-- Add additional source elements for different audio formats -->
<!-- Example: <source src="path/to/audio-file.ogg" type="audio/ogg"> -->
Your browser does not support the audio element.
</audio>
you just remove the loop inside the first paragraph.
Share this insight
This conversation is happening inside the community.
Join free to continue it.The Internet Changed. Now It Is Time to Build Differently.
If this article resonated, the next step is learning how to apply it. Inside Wealthy Affiliate, we break this down into practical steps you can use to build a real online business.
No credit card. Instant access.
