SimplePlaylist

Summary: Simple audio player with a playlist
Version: 2024-05-30
Prerequisites: ExtensionHub
Status: Experimental
Maintainer: Petko
License: MIT
Users: (view? / edit)

Description

Simple audio player with a playlist.

The extension allows to define a simple playlist with wiki markup and wikistyles, which will be rendered as an audio player.

Demo - test the recipe here.

Installation

This extension requires ExtensionHub.

Place SimplePlaylist-2024-05-30.zip in the pmwiki/extensions directory on your server. Optionally you can unzip it.

Alternatively, you can clone the Git repo into pmwiki/extensions with such a command line:
git clone --depth=1 https://github.com/5ko/SimplePlaylist.git

Configuration

To enable the extension, navigate to SiteAdmin.ExtensionHub, locate the "SimplePlaylist" row and press "Edit". On the new page, check the checkbox "Enable configuration" and near the bottom press "Save".

You can check the checkboxes to enable options by default for all players:

  • shuffle - Shuffle the tracks when the page is loaded.
  • numbered - Show track numbers.
  • autoplay - Try to play the first track as soon as the page is loaded. This may not work in some browsers, or if the page is opened in a new background tab, or the browser may ask for "autoplay" permissions for the current website.
  • autonext - Automatically play the next track when the current one ends playing.
  • loop - Automatically play the first track when the last one ends playing.

When an option is enabled, you don't need to add it in the wikistyle on a page.

Usage

Create a numbered list with links to your audio files. Add the WikiStyle %list simpleplaylist% on the first item to transform the list into an audio player.

# [[Attach:adventure.mp3|Adventure]] %list simpleplaylist%
# [[https://example.com/ambient-bongos.ogg|Ambient Bongos]]
# [[Path:/music/city-sunshine.m4a|City Sunshine]]
# [[Attach:emotional-blockbuster-2.webm|Emotional Blockbuster 2]]
# [[Attach:stereotype-news.flac|Stereotype News]]

After the page is saved, the list is rendered as an audio player with a playlist:

  1. Adventure
  2. Ambient Bongos
  3. City Sunshine
  4. Emotional Blockbuster 2
  5. Stereotype News
  • Use the audio player controls to play/pause/mute/change volume and seek a different time stamp.
  • Click on a track in the list below to start playing that track.

Optional WikiStyles enable more functionality, you can include zero or more of these:

%list simpleplaylist shuffle autoplay autonext loop numbered%

See Configuration above.

If an option is enabled in the configuration form, you can disable it per-player by adding "x"+ the option name:

%list simpleplaylist xnumbered xautonext% (remove numbers, remove auto-advance)

Demo - test the recipe here.

Notes

This extension can be used together with Ape, but the playlist files should not have any parent nodes matching the selectors expected by Ape (%embed% or %player%).

This extension can be used together with Filterable to insert a search box before the playlist, if you define a custom query selector ol.SimplePlaylist in the Filterable Hub configuration.

To do / some day / maybe

  • Improve error handling, in case of a server error, the player shouldn't try to re-download the file.

Change log / Release notes

  • 2024-05-30: Add configuration form page with options, add way to disable options per-player. Use lowercase classnames, add "numbered". Show current track in blue. Clicking on the current track will now rewind from the start (or fragment) instead of reloading the whole file. The "autoplay" attribute, when enabled, will only be added to the first playlist in a page. Improve intermittent error handling. When playing, pause other players in the page.
  • 2024-05-29a: Allow for lowercase WikiStyle "simpleplaylist" for better compatibility with $LinkWikiWords.
  • 2024-05-29: Improve shuffle function. Improve track numbers for Filterable compatibility.
  • 2024-05-28: Update styles. Replace unused content-types with a simple regexp. Improve Filterable compatibility.
  • 2024-05-27b: Accept 'audio/webm' format.
  • 2024-05-27a: Add error handling.
  • 2024-05-27: First prototype, ready to be tested.

See also

Cookbook /
Ape  Embed videos, maps, documents, and more in wiki pages (Stable)
ExtensionHub  Configuration panel for extensions (Experimental)
Filterable  Search box for long lists and tables (Beta)

Contributors

Written and maintained by Petko. If this recipe helps you or saves you time, you can help support its continued development by .

Comments

See discussion at SimplePlaylist-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.