blob: 0c762ebc4bc53082c3e1fc9f1660c3723f51af7e (
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
|
---
title: HTMLMediaElement.volume
slug: Web/API/HTMLMediaElement/volume
translation_of: Web/API/HTMLMediaElement/volume
---
<p>{{APIRef("HTML DOM")}}</p>
<p><strong><code>HTMLMediaElement.volume</code></strong> 属性可设置媒体播放时的音量。</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="syntaxbox">var <em>volume</em> = <em>video</em>.volume; //1</pre>
<h3 id="值">值</h3>
<p>取值为 0 到 1 的双精度值。0 为静音,1 为音量最大时的值。</p>
<h2 id="示例">示例</h2>
<pre>var obj = document.createElement('audio');
console.log(obj.volume); // 1
obj.volume = 0.75;</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', "#dom-media-volume", "HTMLMediaElement.volume")}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td></td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', "embedded-content-0.html#htmlmediaelement", "HTMLMediaElement.volume")}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.HTMLMediaElement.volume")}}</p>
<h2 id="See_Also" name="See_Also">更多</h2>
<ul>
<li>定义该属性的接口 {{domxref("HTMLMediaElement")}}.</li>
<li>{{domxref("HTMLMediaElement.muted")}}</li>
</ul>
|