Various events are sent by the HTML5 audio element. This section lists the events and provides helpful information about using them.
The sound and group classes provide methods bind, bindOnce, unbind and trigger to manage events.
mySound.bind("loadstart", function () { document.getElementById("loading").style.display = "block"; }).bind("loadeddata error", function () { document.getElementById("loading").style.display = "none"; });
Sent when playback is aborted; for example, if the media is playing and is restarted from the beginning, this event is sent.
Sent when enough data is available that the media can be played, at least for a couple of frames. This corresponds to the CAN_PLAY readyState.
Sent when the ready state changes to CAN_PLAY_THROUGH, indicating that the entire media can be played without interruption, assuming the download rate remains at least at the current level.
Sent when the ready state changes to DATA_UNAVAILABLE.
The meta data has loaded or changed, indicating a change in duration of the media. This is sent, for example, when the media has loaded enough data that the duration is known.
The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the load() method is called to reload it.
Sent when an error occurs and the media is empty.
Sent when playback completes.
Sent when an error occurs. The element's error attribute contains more information.
Sent when an error occurs with the source.
The first frame of the media has finished loading.
mySound.bind("loadeddata", function () { document.getElementById("loading").style.display = "none"; });
The media's meta data has finished loading; all attributes now contain as much useful information as they're going to.
Sent when loading of the media begins.
mySound.bind("loadstart", function () { document.getElementById("loading").style.display = "block"; });
Sent when playback is paused.
Sent when playback of the media starts after having been paused; that is, when playback is resumed after a prior pause event.
Sent when the media begins to play (either for the first time, after having been paused, or after ending and then restarting).
Sent periodically to inform interested parties of progress downloading the media. Information about the current amount of the media that has been downloaded is available in the media element's buffered attribute.
Sent when the playback speed changes.
Sent when a seek operation completes.
Sent when a seek operation begins.
Sent when loading of the media is suspended; this may happen either because the download has completed or because it has been paused for any other reason.
The time indicated by the element's currentTime attribute has changed.
mySound.bind("timeupdate", function () { var timer = buzz.toTimer(this.getTime()); document.getElementById("timer") .innerHTML = timer; });
Sent when the audio volume changes (both when the volume is set and when the muted attribute is changed).
mySound.bind("volumechange", function () { document.getElementById("timer").innerHTML = this.getVolume(); });
Sent when the requested operation (such as playback) is delayed pending the completion of another operation (such as a seek).