audio object

Specifies the sound or audio content, such as music or effects, to be played in a document.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4.8.7Internet Explorer 9



The audio object has these types of members:


The audio object has these events.


Occurs when playback is possible, but would require further buffering.


Occurs when playback to end is possible without requiring a stop for further buffering.


Occurs when the duration attribute is updated.


Occurs when the media element is reset to its initial state.


Occurs when the end of playback is reached.


Occurs when media data is loaded at the current playback position.


Occurs when the duration and dimensions of the media have been determined.


Occurs when Internet Explorer begins looking for media data.


Occurs when playback is paused.


Occurs when the play method is requested.


Occurs when the audio or video has started playing.


Occurs to indicate progress while downloading media data.


Occurs when the playback rate is increased or decreased.


Occurs when the seek operation ends.


Occurs when the current playback position is moved.


Occurs when the download has stopped.


Occurs if the load operation is intentionally halted. Starting in Microsoft Edge, also occurs if the media network state becomes NETWORK_IDLE.


Occurs to indicate the current playback position.


Occurs when the volume is changed, or playback is muted or unmuted.


Occurs when playback stops because the next frame of a video resource is not available.



The audio object has these methods.


Returns a string that specifies whether the client can play a given media resource type.


Resets the audio or video object and loads a new media resource.


Pauses the current playback and sets paused to true. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not.


Loads and starts playback of a media resource.



The audio object has these properties.

PropertyAccess typeDescription


Use the preload element instead. The autobuffer property was initially listed in the W3C spec, but has been dropped. No version of Internet Explorer supports it.


Gets or sets a value that indicates whether to start playing the media automatically.


Gets a collection of buffered time ranges.


Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player).



Specifies whether to use Cross-Origin Resource Sharing (CORS) when fetching an image from a site outside the webpage's domain.


Gets the address or URL of the current media resource (video,audio) that is selected by IHTMLMediaElement.


Gets or sets the current playback position, in seconds.


Get or sets the current state of the muted attribute.


Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource.


Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming.


Gets information about whether the playback has ended or not.


Returns an object representing the current error state of the audio or video element.


Gets the earliest possible position, in seconds, that the playback can begin. The initialTime property was initially listed in the W3C specification, but has been dropped. No new version of Internet Explorer supports it.


Gets or sets a flag to specify whether playback should restart after it completes.


Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted.


Gets the current network activity for the element.


Gets a flag that specifies whether playback is paused.


Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource.


Gets TimeRanges for the current media resource that has been played.


Gets or sets a hint to how much buffering is advisable for a media resource, even if autoplay isn't specified.

readyState (media, audio, video)


Gets the current state of an audio or video resource.


Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked.


Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource.


The address or URL of the a media resource (videoaudio) that is to be considered.


Gets or sets the volume level for audio portions of the media element.


Standards information


Beginning with Windows Internet Explorer 9, any audio or video content needs the correct mime type set on the server, or the files won't play. Internet Explorer 9 and later support MP3 audio, and MP4 audio and video. WebM audio and video files can be supported by installing the WebM components from The WebM project. The following table shows the required settings for your web server to host these files correctly. Microsoft Edge updates introduced WAV support.

Media file to serveExtension settingMime type setting
Audio mp3mp3audio/mpeg
Audio mp4 m4aaudio/mp4
Audio WebMwebmaudio/webm
Video mp4mp4video/mp4
Video webmwebmvideo/webm
Audio WAV.wavaudio/wav, audio/wave, audio/x-wave, audio/vnd.wave


Note  If you are developing locally or on an intranet and have rendering issues for HTML5, you can add a "meta http-equiv-'X-UA-Compatible' content= " meta command, followed by "IE=edge" to the <head> block of a webpage to force Internet Explorer to use the latest standards. For more information about document compatibility, see Defining Document Compatibility.

The following extensions are available to the Audio object when used in a Windows Store app using JavaScript.

Microsoft ExtensionDescription
msClearEffects Clears all effects from the media pipeline.
msInsertAudioEffect Inserts the specified audio effect into media pipeline.
msSetMediaProtectionManager Specifies the media protection manager for a given media pipeline.
msAudioCategory Specifies the purpose the audio or video media, such as background audio or alerts.
msAudioDeviceType Specifies the output devices that the audio will be sent to.
msPlayToDisabled Gets or sets whether the DLNA PlayTo device is available.
msPlayToPrimary Gets or sets the primary DLNA PlayTo device.
msPlayToSource Gets the source associated with the media element for use by the PlayToManager.
msRealTime Specifies whether or not to enable low-latency playback on the media element.


For information on audio formats supported on the Audio tag when used in a Windows Store app using JavaScript, see Supported audio and video formats.

For an example of audio and video playback in a Windows Store app using JavaScript, see the HTML media playback sample.

For additional information on creating Windows Store apps using JavaScript, see Roadmap for Windows Store apps using JavaScript.

For additional information on playing audio and video in a Windows Store app using JavaScript, see Adding multimedia. For information on audio and video performance, see Audio and video performance.


The following code example plays an MP3-format audio file.

Using one of the following formats, type the name of an MP3-format audio file in the text box:

  • Local file syntax: "file://C:\yourfilepath.mp3"
  • Web file syntax: "http://webfilepath.mp3"
The example uses two events to toggle the play button. Put the path of an MP3 into the text box, and click the Play button. No path is needed if your audio file is in the same folder as the source code of the example.

If there isn't a file to load and play, the example will give a unknown error if you click the audio's control button, or an invalid source error when the Play button is pressed.

Try the example online.

 <!DOCTYPE html>
    <title>Simple Audio Example</title>
  <h1>Simple HTML5 audio example</h1>
  <audio id="audio1" style="width:50%" controls >Not supported</audio>
  <br />
  Click audio control's play to restart on same file, 
  <br />
  Type an MP3 file path here and click Play 
  <br />
  <input type="text" id="audioFile" size="60" />

  <button id="playbutton">Load</button>
    var audioElm = document.getElementById("audio1");
    var button = document.getElementById("playbutton");

    //  Alternates between play and pause based on the value of the paused property
    button.addEventListener("click", function () {
      if (audioElm) {
        if (audioElm.paused == true) {
          // always loads new file
          audioElm.src = document.getElementById('audioFile').value;
        } else {
    }, false);

    //  capture pause and play event and toggle the button's label
      document.getElementById("playbutton").innerText = "load"; // button text == play

    audioElm.addEventListener("play", function () {
      document.getElementById("playbutton").innerText = "Pause"; // button text == Pause
    }, false);

See also

How to use HTML5 to Add an Audio Player to your Webpage