SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist Barnum's Avatar
    Join Date
    Oct 2008
    Posts
    418
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How do I add MP audio file

    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...

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,207
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    The simplest way is to place it somewhere in your web files (like you would an image) and then link to it:

    Code:
    <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 new HTML5 audio element, but if you want to support older browsers it's best to stick to Flash.

  3. #3
    SitePoint Evangelist Barnum's Avatar
    Join Date
    Oct 2008
    Posts
    418
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ralph, thank you...the simpler version worked like a charm. Simple is my middle name...

    I appreciate your help....

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,207
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    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:

    Code:
    <audio controls>
      <source src="myfile.mp3">
    </audio>
    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).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •