This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

length

Summary

Returns the number of ranges in the object.

Property of apis/audio-video/TimeRangesapis/audio-video/TimeRanges

Syntax

Note: This property is read-only.

var result = TimeRanges.length;

Return Value

Returns an object of type unsigned longunsigned long

Examples

Given a video element with the ID "myVideo", this example looks at the time ranges to determine if the entire video has been loaded.

var v = document.GetElementById("myVideo");

var buf = v.buffered;

var numRanges = buf.length;

if (buf.length == 1) {
  // only one range
  if (buf.start(0) == 0 && buf.end(0) == v.duration) {
    // The one range starts at the beginning and ends at
    // the end of the video, so the whole thing is loaded
    var videoLoaded = true;
  }
}

Related specifications

W3C HTML5 Specification
W3C Editor’s Draft

Attributions