How to add background audio to your website
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>
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.
Recent Comments
3
Some good info, Stefan!
Jeff
Thanks I will try do more short informational videos if the opportunity presents itself again.
Sounds good, Stefan!