Fandom Developers Wiki
Advertisement

HTML5AudioPlayer le permite reproducir archivos de audio con el reproductor de audio nativo de HTML5. Los formatos de audio admitidos dependen del navegador (consulte la tabla a continuación).

Instalación[]

Uso[]

<div class="html5audio" data-file="URL-to-file">Debes habilitar JavaScript para reproducir este audio</div>

Required parameters[]

  • data-file — A full URL to the file. For locally-hosted files, for example "File:Audio.ogg", this is "https://static.wikia.nocookie.../Audio.ogg/revision/latest". You can also use the redirect paths "/Special:FilePath/Audio.ogg", "Special:Redirect/file/Audio.ogg", or the magic word {{filepath:Audio.ogg}}.

Parámetros opcionales[]

  • data-volume — Especifica el volumen del audio. Debe ser un número entre 0.0 y 1.0, con 0.0 en silencio y 1.0 en volumen completo. El valor predeterminado es 1.0.
  • data-download — Especifica si se muestra un botón de descarga. El valor disponible es false. Cualquier otra cosa es igual a true.
  • data-preload — Especifica si y cómo se debe cargar el audio cuando se carga la página. Los valores disponibles son auto, metadata y none. El valor predeterminado es none.
  • data-start A time (in seconds) to start the audio from. The user can still manually seek to before this point.
  • data-end A time (in seconds) to automatically pause the audio. This will only occur once, and users can still manually seek to after this point.
  • data-repeat-start A time (in seconds) of the start of the repeat. Once repeat-end is hit, playback will jump to this time. Defaults to 0.0, but only if a repeat-end value is set.
  • data-repeat-end A time (in seconds) of the end of the repeat. Once hit, the playback will jump to repeat-start. If this time is before the repeat-start time, the repeat instead behaves like a skip function. Users can still manually seek after this time without a repeat occurring. Defaults to the duration of the audio, but only if a repeat-start value is set. Loop and repeat may be used simultaneously, but note that neither have particularly high precision, and are unsuitable for seamless playback.
  • data-options — Acepta alguna o varias de las siguientes opciones separadas por comas:
    • autoplay — Especifica que el audio comenzará a reproducirse tan pronto como esté listo.
    • loop — Especifica que el audio comenzará de nuevo cada vez que termine.
    • muted — Especifica que la salida de audio debe silenciarse.

Ejemplo[]

Ejemplo con todos los parámetros en uso:

<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="loop">Debes habilitar JavaScript para reproducir este audio</div>


Results in the following:

Debes habilitar JavaScript para reproducir este audio

Formatos compatibles con el navegador[]

Format Chrome Edge Firefox Opera Safari
AAC SI SI SI[1] SI SI
ALAC NO NO NO NO SI
MP3 SI SI SI SI SI
FLAC SI SI SI NO SI
Opus SI SI SI SI NO
OGG (Vorbis) SI SI SI SI NO
WAV SI SI SI SI SI
  1. Firefox only supports AAC within an MP4 container, and only when the operating system has the supported codecs installed.

De W3Schools

Ver también[]

Advertisement