enable download button for html5 audio player in chrome
const audio = `<audio preload="auto" controls="controls"> <source src="https://archive.org/download/testmp3testfile/mpthreetest.mp3" type="audio/mp3"> </audio>`;document.getElementById('song').insertAdjacentHTML('beforeend', audio);
<div id="song"></div>
If you put a real MP3 file as src is showing the download button even adding the audio
element dinamically with Javascript. I suppose that it checks and preloads the file and when success fills the controls...
i had the the same problem. i finally found a solution for this.
at first i just tried to let it download the .ogg
.wav
or .mp3
file this made it open in another tab in my browser but did not let me download it. now i treid to put the .ogg
file into a zip folder and try to let it download the folder which was the solution for my froblem.
the code i use for this:
<button> <a href="HooniganProds\songs.zip" download>Click to Download!</a> </button>