Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Audio readyState attribute

Audio readyState attribute

Audio Object Reference Audio object

Example

Get the ready state of the audio:

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

document.getElementById("demo").innerHTML = x;

x Output result:

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

Try it »


Definition and Usage

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

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

Note: This attribute is read-only.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the readyState attribute.

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


Syntax

audioObject

.readyState

Return Value

Type Description
Numeric value

Represents 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 ready state
  • 2 = HAVE_CURRENT_DATA - data about the current playback position is available, but 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 - enough data is available to start playing
  • |

    Audio Object Reference Audio object