aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/timeranges/start/index.html
blob: 48f53a9a02eb1478f821ebc061f84f7e1cce605c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: TimeRanges.start()
slug: Web/API/TimeRanges/start
translation_of: Web/API/TimeRanges/start
---
<p>{{APIRef("DOM")}}</p>

<p>{{gecko_minversion_header("2.0")}}</p>

<p>返回指定时间范围的开始偏移量。</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox"><em>startTime</em> = TimeRanges.start(index)
</pre>

<h3 id="参数">参数</h3>

<ul>
 <li><code>index</code> 想要检索的时间范围的索引值。</li>
</ul>

<h3 id="异常">异常</h3>

<dl>
 <dt>INDEX_SIZE_ERR</dt>
 <dd>如果不存在指定索引值的时间范围,抛出 <code>DOMException</code> 异常。</dd>
</dl>

<h2 id="示例">示例</h2>

<p>假定页面中存在一个ID为“myVideo”的 video 元素:</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>这个例子演示了如何通过 <code>TimeRanges</code> 来判断 video 是否已经完全加载。</p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName("HTML WHATWG", "#dom-timeranges-start", "TimeRanges.start()")}}</td>
   <td>{{Spec2("HTML WHATWG")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("api.TimeRanges.start")}}</p>