tags:

views:

131

answers:

3

I need to play a mp3 audio file when the user clicks on a image. I only want to audio to play, i.e. there should be no controls, widgets, etc. Nor should the browser launch an external application.

Edit: ok, I might be able to try out flash. recommendations for a lightweight flash player?

+1  A: 

You could do this:

<embed src="blah.wav" autostart=false loop=false>

... but playing sound without flash is evil and will lead to issues cross browser even if there is some solutions.

You could also use HTML5 and the audio tag:

<audio src="horse.ogg" controls="controls">
Your browser does not support the audio element.
</audio>

... but this won't be supported by all browsers.

EDIT: For a flash player you could use this one or this very simple one... there are tons! Try out examples and see what's best for you.

marcgg
thanks for the suggestion. the flash audio players are, however, too complex. i need a very basic flash script that can be launched using javascript.
Evenz495
+1  A: 

I'm not sure if you can still benefit from these, but SoundManager 2 and jPlayer are two easy to use audio players. Both are instantiated using JavaScript, call a Flash file behind the scenes, and can be styled using HTML and CSS.

Mike Branski
A: 

Let me correct this. With HTML5 .ogg file will play in FireFox only. Adding Controls element will display controls, to hide controls simply do not add controls element, but again it will only work in FireFox with .ogg file. FireFox does not support MP3 files in HTML5, only Chrome and Safari so far, may be IE9 will later. Your best bet is Flash. Good luck.

alby1481