Advertisement
Home Open Editor ❯

HTML Audio/Video DOM volume Property

Example

var vid = document.getElementById("myVideo");

function getVolume() {
  alert(vid.volume);
}

function setVolume(x) {
  vid.volume = x;
}

Try this code ❯

Meaning

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

Return a Number value, Specifies the current volume and the default value is 1.0.


Standard Syntax

Return the volume property:

audio|video.volume

Set the volume property:

audio|video.volume=number


Advertisement

Property Value

Type Description
number Specifies the current volume of the audio/video.

Example values:

  • 0.0 is silent (mute).
  • 0.5 is half volume (50%).
  • 1.0 is highest volume (100%. This is default).

Note: Must be a number between 0.0 and 1.0.

Home Open Editor ❯
Advertisement