$begingroup$![Image Image](http://misfitgeek.com/postimages/PlaySoundUI.png)
![Play Play](http://www.herongyang.com/HTML/HTML5-audio-and-video-Example.jpg)
Definition and Usage. The play method starts playing the current audio. Tip: This method is often used together with the pause method. Tip: Use the controls property to display audio controls (like play, pause, seeking, volume, etc, attached on the audio). Create a custom HTML5 audio player with JS, HTML, and CSS. Blog Portfolio Building a Custom HTML5 Audio Player With Javascript Sun, May 4, 2014. Calculating the click’s position as a percent of the timeline’s width, and updating the playhead and track positions.
I want to add a short audio track to a game of concentration I'm coding. I want the sound to occur when the user has won the game. How do I go about doing this?I would really appreciate the help, thank you.
Sarah AshleighSarah Ashleigh
$endgroup$4 Answers
$begingroup$![Image Image](http://misfitgeek.com/postimages/PlaySoundUI.png)
If you're using something like canvas and you're already depending on the browser supporting HTML5, you can use the
audio
element.Some GuySome Guy
$endgroup$$begingroup$Audio in HTML5 is a minefield at the moment, with patchy format support.
We wrote a few blog posts about audio support in HTML5. This chart shows browser support:http://www.scirra.com/blog/44/on-html5-audio-formats-aac-and-ogg#chart
Surprisingly, IE doesn't support playback of WAVs. You should pick audio 2 formats to get coverage on all the platforms.
Beware using MP3's in games
It will cost you $2,500 per title in licensing fees if it has more than 5,000 distributions.http://www.scirra.com/blog/64/why-you-shouldnt-use-mp3-in-your-html5-games
We think the best combination to use is AAC/Ogg to cover all browsers.
Tom GullenTom Gullen
$endgroup$$begingroup$I found an article describing this library which should fit your needs.
![Play Play](http://www.herongyang.com/HTML/HTML5-audio-and-video-Example.jpg)
If you don't have sound files yet and want to create them with some fx library then you might want to look at jsfx which I used in my last game typdown (specially these two files are interesting (don't mind the coffeescript, it all compiles to javascript): sounds and game controller
Thomas R. KollThomas R. Koll
$endgroup$$begingroup$The Web Audio API is perfect for playing audio in javascript, but currently only Chrome supports it.
AshleysBrainAshleysBrain
$endgroup$