THE WORLD'S LARGEST WEB DEVELOPER SITE

Audio play() Method

❮ Audio Object

Example

An audio player with play and pause buttons:

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

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

function pauseAudio() {
  x.pause();
}
Try it Yourself »

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).


Browser Support

Method
play() Yes 9.0 Yes Yes Yes

Syntax

audioObject.play()

Parameters

None

Return Value

No return value

❮ Audio Object