Play an HTMLAudioElement in JavaScript

An HTMLAudioElement is a type of HTMLMediaElement.
It allows you to access, open, load, and play an audio file in JavaScript, just as you can do with the <audio> tag in HTML, and it thus provides you scripting access to the properties, methods, and events of the Audio element.

For example, you can play a file with time stretching or time compression,
by changing its playbackRate property.


It's also possible to use an HTMLAudioElement as a source AudioNode in the Web Audio API.


This page was last modified April 3, 2016
by Christopher Dobrian, dobrian@uci.edu