Execute a JavaScript when the duration of a video has changed:
<!DOCTYPE html> <html> <body> <video controls ondurationchange="myFunction()"> <source src="video.mp4" type="video/mp4"> <source src="video.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video>/*w ww. j a v a2 s .c o m*/ <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = "The video duration has changed"; } </script> </body> </html>
The ondurationchange event occurs when the duration of the audio/video is changed.
When the audio/video is loaded, the duration will change from "NaN" to the actual duration of the audio/video.
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <audio> and <video> |