TimeRanges
When loading a media resource for use by an <audio>
or <video>
element, the TimeRanges
interface is used for representing the time ranges of the media resource that have been buffered, the time ranges that have been played, and the time ranges that are seekable.
A TimeRanges
object includes one or more ranges of time, each specified by a starting time offset and an ending time offset. You reference each time range by using the start()
and end()
methods, passing the index number of the time range you want to retrieve.
Normalized TimeRanges objects
Several members of HTMLMediaElement
objects return a normalized TimeRanges object — which the spec describes as having the following characteristics:
The ranges in such an object are ordered, don't overlap, and don't touch (adjacent ranges are folded into one bigger range). A range can be empty (referencing just a single moment in time).
Properties
-
TimeRanges.length
Read only -
Returns an
unsigned long
representing the number of time ranges represented by the time range object.
Methods
TimeRanges.start()
-
Returns the time for the start of the range with the specified index.
TimeRanges.end()
-
Returns the time for the end of the specified range.
Specifications
Specification |
---|
HTML Standard (HTML) # time-ranges |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
TimeRanges |
6 |
12 |
4 |
9 |
≤12.1 |
3.1 |
≤37 |
18 |
4 |
≤12.1 |
2 |
1.0 |
end |
6 |
12 |
4 |
9 |
≤12.1 |
3.1 |
≤37 |
18 |
4 |
≤12.1 |
2 |
1.0 |
length |
6 |
12 |
4 |
9 |
≤12.1 |
3.1 |
≤37 |
18 |
4 |
≤12.1 |
2 |
1.0 |
start |
6 |
12 |
4 |
9 |
≤12.1 |
3.1 |
≤37 |
18 |
4 |
≤12.1 |
2 |
1.0 |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TimeRanges