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