DOM Properties
HTMLMediaElement.readyState
Numeric readiness from HAVE_NOTHING (0) to HAVE_ENOUGH_DATA (4). It describes data availability, not playback permission or guaranteed uninterrupted playback. The intermediate values are HAVE_METADATA (1), HAVE_CURRENT_DATA (2) and HAVE_FUTURE_DATA (3). Use the named constants to express the amount of data needed for a UI decision. The example tests the no-resource state; it does not measure playback. Example result: true.
Formal Syntax & Structure
html syntaxhtml
media.readyStateReturn Value
number
Integer from 0 through 4 describing media data readiness.
Working Example
Example Snippethtml
<p> Result: <output id="result"></output></p><script> const result = document.getElementById("result"); (async () => { const media = document.createElement("audio"); document.body.append(media); result.textContent = media.readyState === HTMLMediaElement.HAVE_NOTHING; })().catch(error => { result.textContent = "Error: " + error.name; });</script>