Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 audio tag in which Download possible?

I used audio tag of HTML5 and put 1 button for download that can any functionality provide by audio tag that we directly download as mp3 file.

<audio id="range" src="audio/1.mp3" type="audio/mp3" controls="controls">
  <a href='audio/1.mp3'>DownloadButton</a> 
</audio>
//used .play() , .volume() , .pause()  working proper

Above functionality i tried but not working which i want. I want just click on button and direct downloaded that audio file. Please tell me if any one know proper way than guide me.!

The Chrome browser is used.

like image 315
Gunjan Patel Avatar asked Sep 16 '25 11:09

Gunjan Patel


1 Answers

If you're just going to download the file, you don't need <audio> tags, which are for playing the file, not downloading, you can of course use both, but the anchor has nothing to do with the audio tag

<audio id="range" src="audio/1.mp3" type="audio/mp3" controls="controls"></audio>

<a href="audio/1.mp3" download="filename.mp3">DownloadButton</a> 
like image 195
adeneo Avatar answered Sep 18 '25 08:09

adeneo