FANDOM


HTML5AudioPlayer allows you to play audio files with HTML5's native audio player. The supported audio formats depend on the browser (consult table below).

Installation

Usage

<div class="html5audio" data-file="URL-to-file">You need to enable JavaScript to play this audio</div>

Optional parameters

  • data-volume — Specifies the volume of the audio. Must be a number between 0.0 and 1.0, with 0.0 being muted and 1.0 being full volume. Default is 1.0.
  • data-download — Specifies whether to show a download button. Available value is false. Anything else equals to true.
  • data-preload — Specifies if and how the audio should be loaded when the page loads. Available values are auto, metadata and none. Default is none.
  • data-options — Accepts any or several of the following options separated by commas:
    • autoplay — Specifies that the audio will start playing as soon as it is ready.
    • loop — Specifies that the audio will start over again, every time it is finished.
    • muted — Specifies that the audio output should be muted

Example with all parameters in use:

<div class="html5audio" data-file="https://upload.wikimedia.org/wikipedia/commons/5/50/Chopin_Cello_Sonata_Op._65_-3.ogg" data-volume="0.7" data-download="false" data-preload="metadata" data-options="autoplay,loop">You need to enable JavaScript to play this audio</div>

Supported formats by browser

Browser MP3 Wav Ogg
Internet Explorer YES NO NO
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Opera YES YES YES

From W3Schools

Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+