Latest web development tutorials

HTML DOM Audio play () method

Audio Object Reference Audio Object

Examples

With play and pause buttons piece of audio:

var x = document.getElementById ( "myAudio");

function playAudio ()
{
x.play ();
}

function pauseAudio ()
{
x.pause ();
}

try it"

Definition and Usage

play () method to start playing the current audio.

Note: This method is usually the pause () used with the method.

Tip: Use the controls property to display the audio controls (such as audio on: play, pause, seeking, volume , etc.).


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the play () method.

Note: Internet Explorer 8 or earlier browser does not support this method.


grammar

audioObject .play()

parameter

None

return value

No return value


Audio Object Reference Audio Object