Javascript examples for DOM HTML Element:Audio
The readyState property returns the current ready state of the audio, which tells if the audio is ready to play or not.
This property is read-only.
Type | Description |
---|---|
Number | Represents the ready state of the audio element: |
Which could have the following value:
The following code shows how to get the current ready state of the audio:
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls> <source src="your.ogg" type="audio/ogg"> <source src="your.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>/*from www.j a v a 2 s . c o m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myAudio").readyState; document.getElementById("demo").innerHTML = x; } </script> </body> </html>