HTML and CSS Reference
In-Depth Information
true or false . Set when an audio object has played through its entire duration .
URL to the source file for the audio object.
Specifies whether the media file should be loaded before the page is displayed. At
the time of this writing, this property has not been implemented across all browsers.
To see which properties and events of the HTMLMediaObject are suppor-
ted in which browsers, visit
vents.html .
Important Audio Events
Many events are defined for the HTML5 audio element. We are going to focus on the
following events because they have proven to work when building audio applications:
Raised when the browser is retrieving data while loading the file. (This still has
spotty support in browsers, so be careful with it.)
Raised when the browser calculates that the media element could be played from
beginning to end if started immediately.
Set to true when the audio is being played.
Set when either the volume property or the muted property changes.
Set when playback reaches the duration of the audio file and the file stops being
Loading and Playing the Audio
We are going to use the canplaythrough and progress events to load <audio> before we
try to play it. Here is how we embed the audio for song1 :
<audio id="theAudio" controls>
<source src="song1.mp3" type="audio/mp3">
<source src="song1.wav" type="audio/wav">
<source src="song1.ogg" type="audio/ogg">
Your browser does not support the audio element.
Search WWH ::

Custom Search