HTML Audio / Video DOM volumechange event
HTML Audio / Video DOM Reference
Examples
Volume change when the video message pops up:
var vid = document.getElementById ( "myVideo");
vid.onvolumechange = function () {
alert ( "volume has changed.");
};
vid.onvolumechange = function () {
alert ( "volume has changed.");
};
try it"
Bottom of this article contains more examples.
Definition and Usage
Volumechange trigger event in the audio / video (audio / video) volume change.
The event cited the case of:
- Increase or decrease the volume
- Mute or unmute
Tip: Use the Audio / Video object's volume property to set or return to the audio / video (audio / video) volume.
Browser Support
Figures in the table represent the first browser to support this version of events.
event | |||||
---|---|---|---|---|---|
volumechange | Yes | 9.0 | Yes | Yes | Yes |
grammar
In HTML:
<Audio | video onvolumechange = "myScript "> try
In JavaScript:
audio | video .onvolumechange = function () {myScript}; try
JavaScript, use the addEventListener () method:
audio | video .addEventListener ( "volumechange" , myScript); try
Note: Internet Explorer 8 and earlier versions of IE do not support addEventListener () method.
technical details
Supported HTML tags: | <Audio> and <video> |
---|---|
Supported JavaScript Objects: | Audio, Video |
More examples
Examples
When the audio volume changes pop up message:
var aud = document.getElementById ( "myAudio");
aud.onvolumechange = function () {
alert ( "volume has changed!");
};
aud.onvolumechange = function () {
alert ( "volume has changed!");
};
try it"
HTML Audio / Video DOM Reference