HTML & CSS
Someone sent me an audio file that I would to share on my website. How do I do this? Do I upload like a photo, and if so, where do I upload it to. Have never had the occasion to do this before...
The simplest way is to place it somewhere in your web files (like you would an image) and then link to it:
<a href="myfile.mp3">Listen Now</a>
That way, when users click on the link they will either see a new browser page with default controls for playing the audio file, or they will be prompted to download the file—depending on the browser. That's a pretty low tech option, though.
There are fancier options, like using [Flash, or even using the [URL="http://html5doctor.com/native-audio-in-the-browser/"]new HTML5 audio element](http://flash.flowplayer.org/plugins/streaming/audio.html), but if you want to support older browsers it's best to stick to Flash.
Ralph, thank you...the simpler version worked like a charm. Simple is my middle name...
I appreciate your help....
Glad that helped, Barnum. Yes, simple is beautiful, and browsers handle audio files pretty nicely these days when you just provide a simple link like that.
The new audio element is also very simple, and you can just do it like this:
That way, the user doesn't have to go to a new page. Unfortunately, though, the <audio> element isn't supported in older browsers, so a fallback is needed (like Flash). The other issue is that not all browsers support the same file types, so sometimes just an mp3 version may not be enough—and thus the simplicity is lost somewhat. Anyhow, that code above works pretty well in a lot of browsers, so worth playing with it (if just to see what it's like).
This topic is now closed. New replies are no longer allowed.