Use an HTMLMediaEvent as an AudioNode

In the Web Audio API you can use an Audio element as a source AudioNode.

In this example, the sound source is an Audio element that's brought into the AudioContext as a MediaElementSourceNode.
It's connected to a GainNode so that it can be smoothly faded in and out.


For even more complete and precise control of playing a sound in the Web Audio API,
you should load the sound data into an AudioBuffer and create an AudioBufferSourceNode in the audio context,
and then you can start and stop that AudioBufferSourceNode with precisely scheduled timing.

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