DOM Properties
HTMLMediaElement.networkState
Resource-fetching state: NETWORK_EMPTY (0), NETWORK_IDLE (1), NETWORK_LOADING (2), NETWORK_NO_SOURCE (3). Do not confuse it with readyState. An idle fetch does not imply that all content is buffered, and a loading fetch does not imply that playback is possible. Use networkState for fetch status and readyState for data availability; a newly created audio element without a source has NETWORK_EMPTY. Example result: true.
Formal Syntax & Structure
html syntaxhtml
media.networkStateReturn Value
number
Integer from 0 through 3 describing resource fetching status.
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.networkState === HTMLMediaElement.NETWORK_EMPTY; })().catch(error => { result.textContent = "Error: " + error.name; });</script>