DOM Properties
TimeRanges.length
Counts intervals in the range object. An empty range has length zero; check it before accessing boundaries. Indices begin at zero. Accessing start(length) or end(length) is out of range. When intervals exist, each pair describes a start and end time in seconds; length counts those pairs, not seconds. Example result: 0.
Formal Syntax & Structure
html syntaxhtml
ranges.lengthReturn Value
number
Nonnegative count of intervals in this TimeRanges object.
Working Example
Example Snippethtml
<p> Result: <output id="result"></output></p><script> const result = document.getElementById("result"); (async () => { const media = document.createElement("audio"); document.body.append(media); result.textContent = media.buffered.length; })().catch(error => { result.textContent = "Error: " + error.name; });</script>