AudioTrackList: change event

The change event is fired when an audio track is enabled or disabled, for example by changing the track's enabled property.

Bubbles No
Cancelable No
Interface Event
Event handler property onchange

Examples

Using addEventListener():

const videoElement = document.querySelector('video');
videoElement.audioTracks.addEventListener('change', (event) => {
    console.log(`'${event.type}' event fired`);
});

// changing the value of `enabled` will trigger the `change` event
const toggleTrackButton = document.querySelector('.toggle-track');
toggleTrackButton.addEventListener('click', () => {
  const track = videoElement.audioTracks[0];
  track.enabled = !track.enabled;
});

Using the onchange event handler property:

const videoElement = document.querySelector('video');
videoElement.audioTracks.onchange = (event) => {
    console.log(`'${event.type}' event fired`);
};

// changing the value of `enabled` will trigger the `change` event
const toggleTrackButton = document.querySelector('.toggle-track');
toggleTrackButton.addEventListener('click', () => {
  const track = videoElement.audioTracks[0];
  track.enabled = !track.enabled;
});

Specifications

Specification Status
HTML Living Standard
The definition of 'change' in that specification.
Living Standard

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
change eventChrome Full support 45
Disabled
Full support 45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled). To change preferences in Chrome, visit chrome://flags.
Edge Full support 12Firefox Full support 33
Disabled
Full support 33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE Full support 10Opera Full support 32
Disabled
Full support 32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled).
Safari Full support 6.1WebView Android Full support 45Chrome Android Full support 45
Disabled
Full support 45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled). To change preferences in Chrome, visit chrome://flags.
Edge Mobile Full support YesFirefox Android Full support 33
Disabled
Full support 33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Opera Android Full support 32
Disabled
Full support 32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled).
Safari iOS Full support 7.1Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

Document Tags and Contributors

Tags: 
Contributors to this page: Wind1808, wbamberg
Last updated by: Wind1808,