HTML5 audio playback

I would like to support playing sound on a webpage using HTML5. I currently support IE with a built-in media player. The javascript on the page interacts with the media player control to start, stop, skip, change the volume, etc.
I would like to have the same control over audio with HTML5. What interface is available for an audio object?

+6
html5 audio
source share
2 answers

The simplest case would be to place an audio tag in your code using src pointing to your audio file. When you get an element from JavaScript, you get a bunch of methods available .

Example:

var audio_file1 = document.getElementById('audio_tag_id'); audio_file1.play(); 

If you still want to deal with backup cases and show the current player in browsers that still do not support the audio tag (e.g. IE), follow the instructions in this lesson: http://www.html5rocks.com/samples/audio / quick /

+9
source share

See the specification for the interface (but do not expect full implementation in browsers)

+3
source share

All Articles