revision:
The ondurationchange event occurs when the duration data of the specified audio/video is changed. The ondurationchange attribute is part of the event attributes and can be used on the following elements: <audio>, <video>.
<video ondurationchange="script"></video >
example
example audio:
<video style="margin-left:3vw;" controls ondurationchange="videoChange()"> <source src="../../pics/Wuzhen-20-10_02.mp4" type="video/mp4"> Your browser does not support HTML5 video. </video> <script> function videoChange() { alert("The video duration has changed"); } </script>
example video :
<audio id="myAudio" controls ondurationchange="audioChange(this)"> <source style="margin-left:3vw;" src="../../pics/horse.wav" type="audio/wav"> Your browser does not support the audio element. </audio> <script> function audioChange(x) { alert("The duration of this audioclip is : " + x.duration + " seconds"); } </script>