Audio duration Property
Get the length of an audio:
The result of x could be:
Try it yourself »
Definition and Usage
The duration property returns the length of an audio, in seconds.
Note: Different browsers return different values. In the example above, Opera 18+ and Chrome returns "1.515102". Firefox returns "1.509298". Internet Explorer returns "1.5491875". Safari returns "1.5149999856948853", while Opera 12 returns "1.5092970520000002".
Note: This property is read-only.
The duration property is supported in all major browsers.
Note: This property is not supported in Internet Explorer 8 and earlier versions.
|Return Value:||A Number, representing the length of the audio, in seconds. If no audio is set, "NaN" (Not-a-Number) is returned. If the audio is streamed and has no predefined length, "Inf" (Infinity) is returned.|
Thank You For Helping Us!
Your message has been sent to W3Schools.