Audio readyStateProperty

Audio 对象参考手册Audio Object

Example

Get the ready state of the audio:

var x = document.getElementById("myAudio").readyState;
document.getElementById("demo").innerHTML = x;

xOutput result:

4 // indicates there is enough data to start playing the audio

Try it yourself »

Definition and Usage

The readyState property returns the current ready state of the audio.

The ready state indicates whether the audio is ready to play.

Note:This property is read-only.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the readyState property.

Note:Internet Explorer 8 and earlier IE versions do not support this property.


Syntax

audioObject.readyState

Return Value

Type Description
Numeric value

Indicates the ready state of the audio element:

  • 0 = HAVE_NOTHING - No information about whether the audio is ready
  • 1 = HAVE_METADATA - Metadata about the audio is ready
  • 2 = HAVE_CURRENT_DATA - Data about the current playback position is available, but there is not enough data to play the next frame/millisecond
  • 3 = HAVE_FUTURE_DATA - Data for the current and at least the next frame is available
  • 4 = HAVE_ENOUGH_DATA - Available data is enough to start playback


Audio 对象参考手册Audio Object Other extensions