Controlling media playback

Once you’ve embedded media into your HTML document using the new elements, you can programmatically control them from JavaScript code. For example, to start (or restart) playback, you can do this:

var v = document.getElementsByTagName("video")[0];;

The first line fetches the first video element in the document, and the second calls the element’s play() method, as defined in the nsIDOMHTMLMediaElement interface that is used to implement the media elements.
Controlling an HTML5 audio player to play, pause, increase and decrease volume using some Javascript is straightforward.

<audio id="demo" src="audio.mp3">
    <button onclick="document.getElementById('demo').play()">
        Play the Audio
    <button onclick="document.getElementById('demo').pause()">
        Pause the Audio
    <button onclick="document.getElementById('demo').volume+=0.1">
        Increase Volume
    <button onclick="document.getElementById('demo').volume-=0.1">
        Decrease Volume