HTML5AudioPlayer erlaubt das Abspielen von Audiodatein mit einem nativen HTML5 Audio-player. Die Unterstützten Audioformate hängen vom jeweiligen Browser ab (unten in der Tabelle aufgeführt).
Installation
Usage
<div class="html5audio" data-file="URL-to-file">JavaScript muss aktiviert sein, um Audiodatein abspielen zu können</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}}.
Zusätzliche Parameter
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— Legt die Audiolautsärke fest. Die Nummer muss zwischen 0.0 und 1.0 sein, dabei ist 0.0 Stumm und 1.0 die volle Lautstärke. Standartmäßig ist es 1.0.data-download— Legt fest, ob ein Downloadsymbol angezeigt wird. Verfügbarer Wert istfalse. Alles andere ergibt den Werttrue.data-preload— Legt fest ob und wie die Audiodatei geladen wird, während die Seite lädt. Verfügbare Werte sindauto,metadataundnone. Standartmäßig ist 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— Akzeptiert jeden oder mehrere der Folgenden Optionen, durch ein Komma getrennt:autoplay— Legt fest, ob die Audiodatei gestartet wird, sobald diese bereit ist.loop— Legt fest, ob die Audiodatei wiederholt wird, sobald diese geendet ist.muted— Legt fest, ob die Audiodatei Stummgeschaltet ist.
Example
Beispiel mit allen verwendeten Parametern:
<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">JavaScript muss aktiviert sein, um Audiodatein abspielen zu können</div>
Results in the following:
JavaScript muss aktiviert sein, um Audiodatein abspielen zu können
Unterstützte Formate im Browser
| Format | Chrome | Edge | Firefox | Opera | Safari |
|---|---|---|---|---|---|
| AAC | JA | JA | JA[1] | JA | JA |
| ALAC | NEIN | NEIN | NEIN | NEIN | JA |
| MP3 | JA | JA | JA | JA | JA |
| FLAC | JA | JA | JA | NEIN | JA |
| Opus | JA | JA | JA | JA | NEIN |
| OGG (Vorbis) | JA | JA | JA | JA | NEIN |
| WAV | JA | JA | JA | JA | JA |
| |||||
Von W3Schools