Franz Payer
Franz Payer

Reputation: 4137

Downloading from audio html5 tags

In HTML5, is there a way to download the current song in an audio tag? I am feeding it an octet stream that it is playing, but the user cannot directly download the song from the link. Is there a way to allow the user to download the song that is playing? Audio shows up as transparent so there is no way for the user to do a simple right click + save as. Can you encapsulate audio in something that has a save as ability? Or maybe some JavaScript might do the trick?

Upvotes: 4

Views: 5317

Answers (2)

Cat Chen
Cat Chen

Reputation: 2416

You can use a link if it's not a live streaming audio. If it's live streaming, I don't think you can download it with a browser because it doesn't have a finite file size.

If it's a problem about download file naming, you can use content-disposition header. It should be like this:

content-disposition: attachment; filename=playing.mp3

Adding this to the header shouldn't affect the streaming to the audio tag.

Upvotes: 1

PeeHaa
PeeHaa

Reputation: 72652

If the audio is served it means that the audio file is present.

You can even make a link to the audio file and it should work.

Upvotes: 1

Related Questions