TimeRanges.start()

  • Revision slug: Web/API/TimeRanges.start
  • Revision title: TimeRanges.start
  • Revision id: 472711
  • Created:
  • Creator: shubham.hatwar
  • Is current revision? No
  • Comment

Revision Content

{{ DomRef() }}

{{ gecko_minversion_header("2.0") }}

Summary

Returns the time offset at which a specified time range begins.

Syntax

startTime = TimeRanges.start(index) 

Parameters

  • index is the range number to return the starting time for.

Exceptions

INDEX_SIZE_ERR
A DOMException thrown if the specified index doesn't correspond to an existing range.

Example

Given a video element with the ID "myVideo":

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
  }
}

This example looks at the time ranges and looks to see if the entire video has been loaded.

Specification

Revision Source

<p>{{ DomRef() }}</p>
<p>{{ gecko_minversion_header("2.0") }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>Returns the time offset at which a specified time range begins.</p>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre class="eval"><em>startTime</em> = TimeRanges.start(index) 
</pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<ul>
  <li><code>index</code> is the range number to return the starting time for.</li>
</ul>
<h3 id="Example" name="Example">Exceptions</h3>
<dl>
  <dt>
    INDEX_SIZE_ERR</dt>
  <dd>
    A <code>DOMException</code> thrown if the specified index doesn't correspond to an existing range.</dd>
</dl>
<h3 id="Example" name="Example">Example</h3>
<p>Given a video element with the ID "myVideo":</p>
<pre class="brush: js">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 &amp;&amp; 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
  }
}
</pre>
<p>This example looks at the time ranges and looks to see if the entire video has been loaded.</p>
<h3 id="Specification" name="Specification">Specification</h3>
<ul>
  <li><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/#timeranges" title="http://www.whatwg.org/specs/web-apps/current-work/#timeranges">WHATWG Working Draft</a></li>
</ul>
Revert to this revision