How can I get the html5 audio's duration time

前端 未结 8 1535
忘掉有多难
忘掉有多难 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:32

    To obtain the end of reading it is necessary that 'loop = false' with the event 'onended'. If loop = true, onended does not work;)

    To make a playlist, you have to set loop = false to use the 'onended' event in order to play the next song.

    for the duration if your script is done correctly you can recover the duration anywhere. If the value of 'duration' is NaN the file is not found by the browser. If the value is 'Infinity' 'INF' it is a streaming, in this case, adds 1 mn compared to the reading time 'currentime'. For * I.E it's crap. Currenttime may be greater than duration, in which case you do: var duration = (this.currentime> this.duration)? this.currenttime: this.duration;

    That's (O_ °)

提交回复
热议问题