MDN self-hosted library · e01.org

HTMLMediaElement: networkState property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<audio id="example" preload="auto">
  <source src="sound.ogg" type="audio/ogg" />
</audio>
js
const obj = document.getElementById("example");

obj.addEventListener("playing", () => {
  if (obj.networkState === 2) {
    // Still loading…
  }
});