Home > database >  How to prevent automatic download of a linked mp3 file
How to prevent automatic download of a linked mp3 file

Time:07-20

I am making a website using only HTML and CSS. I am trying to link to an online mp3 file (that I do not own) so that the mp3 plays in the browser. This simple code does what I want on Firefox and Safari:

    <a href="https://www.allaboutbirds.org/guide/assets/sound/548271.mp3" >

However, instead of playing the mp3, Chrome automatically downloads the mp3 file to my computer. Is there some way I can alter my HTML code (not my browser preferences) to stop this from happening? Thanks.

CodePudding user response:

You can't guarantee that all the browsers will have a built-in in-frame player for the audio file.

The best thing to do in this case is to embed the audio player into a page with the audio element:

<audio src="https://example.com/some-sound.mp3" controls></audio>
  • Related