blob: 87e262f58d4654a748d4f634fd6b67ace958bff2 (
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
|
---
title: HTMLMediaElement.duration
slug: Web/API/HTMLMediaElement/duration
tags:
- API
- HTML
- Video
- Web
translation_of: Web/API/HTMLMediaElement/duration
---
<div>{{APIRef("HTML DOM")}}</div>
<p><strong><code>HTMLMediaElement.duration</code></strong> 属性以秒为单位给出媒体的长度,如果没有媒体数据可用,则为零。</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="brush: js">var <em>myDuration</em> = <em>audioOrVideo</em>.duration</pre>
<h3 id="值">值</h3>
<p> 如果媒体数据可用但长度未知,则此值为NaN。 如果媒体流式传输且没有预定义长度,则值为Inf。</p>
<h2 id="例子">例子</h2>
<pre class="brush: js">var obj = document.createElement('video');
console.log(obj.duration); // NaN
</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">注释</th>
</tr>
<tr>
<td>{{SpecName('HTML WHATWG', "the-video-element.html#htmlmediaelement", "HTMLMediaElement.duration")}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td>No change from {{SpecName('HTML5 W3C')}}</td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', "embedded-content-0.html#htmlmediaelement", "HTMLMediaElement.duration")}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器支持">浏览器支持</h2>
<p>{{Compat("api.HTMLMediaElement.duration")}}</p>
<h2 id="See_Also" name="See_Also">相关内容</h2>
<ul>
<li>定义它的接口, {{domxref("HTMLMediaElement")}}.</li>
</ul>
|