User:Nardog/PlayAudioNow

This script allows you to click on any link made via the audio template (like ) and listen to the audio without having to move to another page, save the file or open another app, no matter the format—be it Ogg Vorbis, MP3, WebM, FLAC, WAV, or even MIDI, which most browsers don't support natively.

Try it at Help:IPA/Polish, Help:IPA/Swedish, List of chords, etc.

Installation
Add the following to your common.js:

Or you may enable the script installer in and click "Install" in the infobox on this page.

Behavior
By default, clicking on an audio link while the audio is still playing pauses the audio, and clicking on it again resumes it from where it was paused. If you add the following to your common.js, clicking on a paused link will not resume the audio but play it from the beginning:

If you add the following, clicking on a playing link will not pause the audio but play it from the beginning:

If you add the following, you will not be able to pause or stop audio while it's playing:

By default, clicking on a play link while another file is playing pauses (and if the remaining time is less than one second, rewinds) the playing file before playing the new one. Adding the following will allow you to play multiple files at once:

Appearance
By default, the script shows to indicate that a link has been processed by the script so it can be played while staying on the page (and  or  while it's playing; and, an animated SVG using SMIL, while it's loading). This can be modified in your common.css. Since the script's CSS is usually loaded after your custom CSS, a selector for an ancestor element like  or   may be necessary to override the defaults.

The following example replaces the default icons with // and shows for a paused link that will resume the audio, and  for a playing link that will rewind the audio:

This cancels the display of icons entirely:

Limitations
The number of audio files to be processed on a single page is capped at 500 (ten API queries).