THE INDIA LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML Audio/Video DOM volumechange Event

HTML audio Tag Reference HTML Audio/Video DOM Reference

Example

Alert that the volume of a video has been changed:

var vid = document.getElementById("myVideo");
vid.onvolumechange = function() {
    alert("The volume has been changed!");
};
Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

The volumechange event occurs each time the volume of a video/audio has been changed.

This event is invoked by:

  • Increasing or decreasing the volume
  • Muting or unmuting the media player

Tip: Use the volume property of the Audio/Video Object to set or return the audio volume of an audio/video.


Browser Support

The numbers in the table specify the first browser version that fully supports the event.

Event
volumechange Yes 9.0 Yes Yes Yes

Syntax

In HTML:

<audio|video onvolumechange="myScript">Try it

In JavaScript:

audio|video.onvolumechange=function(){myScript};Try it

In JavaScript, using the addEventListener() method:

audio|video.addEventListener("volumechange", myScript);Try it

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.


Technical Details

Supported HTML tags: <audio> and <video>
Supported JavaScript objects: Audio, Video

Examples

More Examples

Example

Alert that the volume of an audio file has been change:

var aud = document.getElementById("myAudio");
aud.onvolumechange = function() {
    alert("The volume has been changed!");
};
Try it yourself »

HTML audio Tag Reference HTML Audio/Video DOM Reference