Latest web development tutorials

HTML Audio / Video DOM volume properties

HTML audio / video Tag Reference HTML Audio / Video DOM Reference

Examples

The video volume set to 20%:

myVid=document.getElementById("video1");
myVid.volume=0.2;

try it"

Definition and Usage

volume property sets or returns the current volume of the audio / video.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support volume attributes.

Note: 8 and earlier versions of Internet Explorer does not support this property.


grammar

Setting volume attributes:

audio|video .volume= volumevalue

Returns volume attributes:

audio|video .volume

Property Value

描述
volumevalue 规定音频/视频的当前音量。必须是介于 0.0 与 1.0 之间的数字。
例值:
  • 1.0 最高音量(默认)
  • 0.5 一半音量 (50%)
  • 0.0 静音

technical details

返回值: 数字值,指示当前的音量。
默认值: 1.0


HTML audio / video Tag Reference HTML Audio / Video DOM Reference