Audio volumeProperty

Audio 对象参考手册Audio Object

Examples

Set the audio volume to 20%:

document.getElementById("myAudio").volume = 0.2;

Try it Yourself »

Definition and Usage

The volume property sets or returns the volume of the audio, from 0.0 (silent) to 1.0 (loudest).

Note:The <audio> element is new in HTML5.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the volume property.

Note:Internet Explorer 8 or earlier browsers do not support this property.


Syntax

Return the volume property:

audioObject.volume

Set the volume property:

audioObject.volume=number

Property Values

Value Description
volumevalue

Specifies the current volume of the audio. Must be a number between 0.0 and 1.0.

Example values:

  • 1.0 is the highest volume (default)
  • 0.5 is half volume (50%)
  • 0.0 is silent

Technical Details

Return Value: A number, representing the volume of the audio.
Default Value: 1.0


Audio 对象参考手册Audio Object Other Extensions