-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
62 lines (41 loc) · 1.14 KB
/
index.md
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
---
title: "TimeRanges: end() method"
short-title: end()
slug: Web/API/TimeRanges/end
page-type: web-api-instance-method
browser-compat: api.TimeRanges.end
---
{{APIRef("DOM")}}
The **`end()`** method of the {{domxref("TimeRanges")}} interface returns the time offset at which a specified time range ends.
## Syntax
```js-nolint
end(index)
```
### Parameters
- `index`
- : The range number to return the ending time for.
### Return value
A number.
### Exceptions
- `IndexSizeError` {{domxref("DOMException")}}
- : Thrown if the specified index doesn't correspond to an existing range.
## Examples
Given a video element with the ID `"myVideo"`:
```js
const v = document.getElementById("myVideo");
const buf = v.buffered;
const 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.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}