Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html: play audio without controls?

Tags:

html

audio

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?

like image 477
Evenz495 Avatar asked Dec 08 '09 11:12

Evenz495


People also ask

How do I autoplay audio in HTML without controls?

The audio tag allows you to embed audio content in your HTML pages. By default the browser does not show any controls for this element. Which means the audio will play only if set to autoplay (more on this later) and the user can't see how to stop it, or control the volume or move through the track.

How do I get HTML to automatically play audio?

The HTML <audio> autoplay attribute is used to specify that the audio should automatically start playing as soon as it is loaded. It is a Boolean attribute.

How do I hide control audio in HTML?

The hidden attribute hides the <audio> element. You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid. A hidden <audio> element is not visible, but it maintains its position on the page.

Can I play audios in HTML?

The HTML <audio> element is used to play an audio file on a web page.


2 Answers

Now there's a way to do it. Put this: <audio src="sounds/game-welcome.mp3" style="display:none;" autoplay> (Replace sounds/game-welcome.mp3 with your file)

like image 163
Inashadow Avatar answered Sep 23 '22 14:09

Inashadow


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.

like image 25
marcgg Avatar answered Sep 25 '22 14:09

marcgg