How can I get the html5 audio's duration time

前端 未结 8 1521
忘掉有多难
忘掉有多难 2020-12-09 15:10

I have a html5 tag in page, but how can I know its duration time?

8条回答
  •  春和景丽
    2020-12-09 15:30

    In a comment above, it was mentioned that the solution is to bind an event handle to the event loadedmetadata. This is how I did that -

    audio.onloadedmetadata = function() {
      alert(audio.duration);
    };
    

提交回复
热议问题