Audio play()Method

Audio 对象参考手册Audio Object

Example

An audio 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 usually used together withpause()the method.

Tip:Usecontrolsthe attribute to display audio controls (such as play, pause, seeking, volume, etc.).


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the play() method.

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


Syntax

audioObject.play()

Parameters

None

Return Value

No return value


Audio 对象参考手册Audio Object Other Extensions