views:

94

answers:

4

I did a lot of searching for what I thought would be a pretty common question, but I came up with nothing. If there is another thread with a similar topic, please let me know.

Basically, I'm looking for a way to have an .mp3 file play in a website without relying on a flash-based player. I've searched w3 schools and every forum I can think of, but every media player I've found so far has been some sort of proprietary flash player.

Doesn't HTML support some sort of native player? I've found some that rely on Windows Media Player which is close, but I want the player to work on an iPhone and something tells me WMP won't get that done...

PS, as I'm thinking more about this this idea just popped into my head: a javascipt player and inside the <noscript> tag, put a flash player? I'm running a music blog (@ http://www.freshoncampus.com) so the less code per post, the better...

+1  A: 

Yes you can, with HTML 5.

This is a pretty good explanation of how you might go about doing this.

The caveat is that HTML5 support is not universal, but iOS devices (iphone) have a good start with supporting HTML5.

Edited to add:

From the question, it's hard to discern if you're looking for a way to play multiple mp3's with a nice gui interface, or just use audio as a background.

For the former, you will need to use Javascript to handle controls, and loading of the src element (I'd search for custom built javascript or jquery plugins to handle this).

For the latter, my solution above will work.

Also, background music in a webpage is highly annoying to most users, so caveat emptor.

Alan
HTML5 audio for iPhone currently doesn't play in the web page, it launchs the media player, plays, then closes. Not what most people want.With iOS4 it will play inline.
Ryan Watkins
The codec support goes for Safari and Chrome... at least from the article you are referencing.
phwd
Thanks, I'm looking for a solution that will give the user a nice GUI to work with. From what I've read, JS is always in use on the iOS so I might use that as my method of choice.
A: 

jplayer? Not sure about MP3/OGG thing though...

Rotsor
A: 

First, HTML5's “audio” tag. Second, you can use “embed” tag — it will play with whatever browser plugin is installed (not just WMP). Not sure what would work in iPhone, though. (and I might be wrong about exact tag names)

Third just link to the mp3 file directly...
Alexandre Jasmin
Directly... Oh, right.Fourth, link to an M3U file with one or more mp3 files (see Jamendo for reference). Useful for opening in an external player (winamp/vlc/…). Even less probable to be usable in iPhone though, I guess.
A: 

You could go with something like http://www.schillmania.com/projects/soundmanager2/ which should autodetect the best option to play the sound.

unomi