Name

TimeRanges — a set of media time ranges

Synopsis

The buffered, played, and seekable properties of a MediaElement represent the portions of a media timeline that have data buffered, that have been played, and that playback can be started at. Each of these portions of the timeline may include multiple disjoint time ranges (this happens to the played property when the user skips to the middle of a video file, for example). A TimeRanges object represents zero or more disjoint time ranges. The length property specifies the number of ranges, and the start() and end() methods return the bounds of each range.

The TimeRanges objects returned by MediaElements are always normalized, which means that the ranges they contain are in order, nonempty and do not touch or overlap.

Properties

readonly unsigned long length

The number of ranges represented by this TimeRanges object.

Methods

double end(unsigned long n)

Returns the end time (in seconds) of time range n, or throws an exception if n is less than zero or greater than or equal to length.

double start(unsigned long n)

Returns the start time (in seconds) of time range n, or throws an exception if n is less than zero or greater than or equal to length.

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.