(Create /doc subpage for Template:Audio) |
m (→Examples: genius) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
This template enhances the regular audio embed with automatic fallback |
This template enhances the regular audio embed with automatic fallback to an MP3, no preloading for faster load times, and no download option. Uses [[w:c:dev:HTML5AudioPlayer|HTML5AudioPlayer]]. |
||
To use, replace any regular audio embed with this template. For example, <code>[<nowiki/>[File:Elevator Jam.ogg]]</code> can be replaced with {{T|Audio|Elevator Jam}}. When played, it tries to play [[:File:Elevator Jam.ogg]], falling back to [[:File:Elevator Jam.ogg.mp3]] if OGG files cannot be played in the current browser. |
To use, replace any regular audio embed with this template. For example, <code>[<nowiki/>[File:Elevator Jam.ogg]]</code> can be replaced with {{T|Audio|Elevator Jam.ogg}}. When played, it tries to play [[:File:Elevator Jam.ogg]], falling back to [[:File:Elevator Jam.ogg.mp3]] if OGG files cannot be played in the current browser. |
||
== Usage == |
== Usage == |
||
{{T|Audio|1|2|no-fallback{{=}}|allow-preload{{=}}}} |
{{T|Audio|1|2|no-fallback{{=}}|allow-preload{{=}}}} |
||
Line 11: | Line 11: | ||
"1": { |
"1": { |
||
"label": "Primary audio file", |
"label": "Primary audio file", |
||
"description": "Name of the primary audio file |
"description": "Name of the primary audio file, without \"File:\".", |
||
"type": "string", |
"type": "string", |
||
"required": true |
"required": true |
||
Line 17: | Line 17: | ||
"2": { |
"2": { |
||
"label": "Fallback audio file", |
"label": "Fallback audio file", |
||
"description": "Name of the audio file to be played when the primary one fails. By default, this is the primary file with .mp3 appended.", |
"description": "Name of the audio file to be played when the primary one fails. Must be a MP3. By default, this is the primary file with \".mp3\" appended.", |
||
"default": "<primary audio file>.mp3", |
"default": "<primary audio file>.mp3", |
||
"type": "string" |
"type": "string" |
||
Line 28: | Line 28: | ||
"allow-preload": { |
"allow-preload": { |
||
"label": "Allow preloading?", |
"label": "Allow preloading?", |
||
"description": "Allows the audio to be embedded when custom JavaScript is not available, |
"description": "Allows the audio to be embedded when custom JavaScript is not available, such as the mobile skin, at the expense of slower load times. Use if the page has a few audio files or if the audio files are small.", |
||
"type": "boolean" |
"type": "boolean" |
||
} |
} |
||
Line 40: | Line 40: | ||
! Template code !! Generates |
! Template code !! Generates |
||
|- |
|- |
||
| '''Typical usage'''<br>{{T|Audio|Elevator Jam}} || {{Audio|Elevator Jam}} |
| '''Typical usage'''<br>{{T|Audio|Elevator Jam.ogg}} || {{Audio|Elevator Jam.ogg}} |
||
|- |
|- |
||
| '''MP3 file'''<br>{{T|Audio| |
| '''MP3 file'''<br>{{T|Audio|Trailer Theme Remix.mp3|no-fallback{{=}}1}} || {{Audio|Trailer Theme Remix.mp3|no-fallback=1}} |
||
|- |
|- |
||
| '''Preloading allowed'''<br>{{T|Audio|Item Shimmer|allow-preload{{=}}1}} || {{Audio|Item Shimmer|allow-preload |
| '''Preloading allowed'''<br>{{T|Audio|Item Shimmer.ogg|allow-preload{{=}}1}} || {{Audio|Item Shimmer.ogg|allow-preload=1}} |
||
|} |
|} |
Latest revision as of 08:02, 2 June 2024
This template enhances the regular audio embed with automatic fallback to an MP3, no preloading for faster load times, and no download option. Uses HTML5AudioPlayer.
To use, replace any regular audio embed with this template. For example, [[File:Elevator Jam.ogg]]
can be replaced with {{Audio|
. When played, it tries to play File:Elevator Jam.ogg, falling back to File:Elevator Jam.ogg.mp3 if OGG files cannot be played in the current browser.
Elevator Jam.ogg
}}
Usage[edit source]
{{Audio|
1
|2
|no-fallback=
|allow-preload=
}}
Parameters[edit source]
No description.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Primary audio file | 1 | Name of the primary audio file, without "File:". | String | required |
Fallback audio file | 2 | Name of the audio file to be played when the primary one fails. Must be a MP3. By default, this is the primary file with ".mp3" appended.
| String | optional |
Disable fallback? | no-fallback | Disables the fallback functionality. Use if the primary audio file is not an OGG file. | Boolean | optional |
Allow preloading? | allow-preload | Allows the audio to be embedded when custom JavaScript is not available, such as the mobile skin, at the expense of slower load times. Use if the page has a few audio files or if the audio files are small. | Boolean | optional |
Examples[edit source]
Template code | Generates |
---|---|
Typical usage{{Audio| |
Play (MP3) }}{{#var: audio-no-js-text}} |
MP3 file{{Audio| |
Play }}{{#var: audio-no-js-text}} |
Preloading allowed{{Audio| |
File:Item Shimmer.ogg (MP3: File:Item Shimmer.ogg.mp3) }}{{#var: audio-no-js-text}} |