HTML Audio/Video DOM volumechange Event

HTML Audio/Video DOM Reference : Alert that the volume of a video has been changed

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

    Technical Details

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

    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!");
    };

    ❮ HTML Audio/Video DOM Reference