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).
Installation
Usage
<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 preferably the magic word{{filepath:Audio.ogg}}.
Parámetros opcionales
data-file-type— Optional MIME type for this file. By default, when this parameter is not provided, the file extension is used to determine the MIME type. This parameter should be used in cases where the file does not have an extension, or when the file extension does not accurately match the MIME type.data-file-n— Used to provide a file fallback, for instances where the file indata-fileisn't playable by the browser. n must be a number greater than 0. You can specify multipledata-file-nattributes with incremental n values to have multiple fallbacks.data-file-type-n— Same asdata-file-type, but for the files provided in eachdata-file-n.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 esfalse. Cualquier otra cosa es igual atrue.data-preload— Especifica si y cómo se debe cargar el audio cuando se carga la página. Los valores disponibles sonauto,metadataynone. El valor predeterminado esnone.data-startA time (in seconds) to start the audio from. The user can still manually seek to before this point.data-endA 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-startA 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-endA 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.
Example
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
| 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 |
| |||||
De W3Schools