The Audio Player module allows you to easily add customizable audio players to your Drupal site, supporting single tracks or playlists. It offers extensive styling options with numerous skins, color palettes, and equalizer effects, integrating seamlessly with Drupal's file and media fields.
The Audio Player module for Drupal 10 and 11 displays audio from File, Media, Link and Text fields and from Views, as single players or playlists. It includes 18 single-player skins, 2 playlist skins, 21 color palettes and 27 equalizer visualizations. Everything is configured on the field's display settings or the view's format settings, without code.
Add an audio field anywhere on the site: content types, block types, paragraphs, media types or any other fieldable entity. Upload one or more audio files and pick a skin. Themers can override the Twig templates and colors; developers can use the audio_player.manager service, alter hooks and a JavaScript API.
What's new in 1.2.0
- More field types: link and plain text fields with audio URLs, and media fields of any file-based media type, not only the core Audio type.
- Configurable playlist heading: change the "Playlist" text or leave it empty to hide it.
- Custom colors (accent, background, text) on top of the palettes.
- Track information: choose the title source, an artist (subtitle) field, a cover image field with an image style, and an optional download link.
- Playback options:
- preload mode, autoplay, loop and initial volume
- rewind/forward step and playback speeds
- start in shuffle and automatic next track
- a cross-origin (CORS) mode for files on S3 or a CDN
- Dock the playing player: a playing player that scrolls out of view stays at the bottom of the screen.
- Remember the playback position: visitors continue where they stopped, even after leaving the page. The position is stored only in their browser.
- Pause other players when one starts.
- Keyboard shortcuts and full keyboard and screen reader support.
- Lock screen and media key controls with title, artist and artwork.
- Simpler theming: two Twig templates instead of twenty, with theme suggestions per skin, entity type, bundle, field and view.
- Developer API:
- the
audio_player.managerservice hook_audio_player_tracks_alter()andhook_audio_player_build_alter()- a JavaScript API
- configuration schema, and unit and kernel tests
- the
- Fixes:
- titles keep umlauts, accents and capital letters
- the global
.hiddenrule is gone - media files no longer show 0:00 durations
- styles of one skin no longer leak into other skins
Features
- Single player or playlist: a field with one file shows a single player. A field with several files shows one player per file, or one playlist with a track list.
- Skins:
- 18 single skins: skins 9–12 show artwork; skins 7–12 and 14–17 have a speed selector; skins 14–17 draw a waveform, bars or bricks while playing.
- 2 playlist skins: a compact list, and a list with artwork and an equalizer.
- Colors: the skin's own colors, one of 20 shared palettes, your own accent, background and text colors, or a palette class in your theme using CSS custom properties.
- 27 equalizer visualizations for playlists, or none.
- Titles: from the file description, media name or link text, or the cleaned file name, with every language's letters kept.
- Playlists: click or press Enter to play a track, previous/next, shuffle, autoplay of the next track, a collapsible track list, durations read without downloading the files, and a download icon per track.
- Accessibility: every control is a labeled button or slider, reachable with the keyboard and visibly focused. Each player is a labeled region. Docking respects reduced motion.
- Works with BigPipe and AJAX: players also start in content loaded later.
- No external libraries: vanilla JavaScript, Drupal core only.
Requirements
- Drupal 10 or 11.
- Core modules: Field, File, Image and Media.
- No contributed modules or external libraries.
Installation
Install as you would normally install a contributed Drupal module. For more information, see Installing Drupal Modules.
composer require drupal/audio_player drush en audio_player
Configuration
Quick start
- Add a File field to a content type (Structure → Content types → (type) → Manage fields) and allow audio extensions, for example
mp3 m4a ogg wav flac. - Go to Manage display, set the field's format to Audio Player and save.
- Create content with an audio file. It plays in the default skin.
- Click the gear icon next to the field on Manage display to choose another skin, palette, playlist and the other options.
Which format to choose
- File field: Audio Player. The file description can be the title.
- Media reference field: Media Audio Player. Any media type that stores a file plays, including the core Audio type and your own types. The media name is the title.
- Link field: Audio Player. The link text can be the title.
- Plain text field: Audio Player, with one audio URL per value.
Settings (on the gear icon of the field, or the format settings of a view)
- Appearance:
- Audio display: single player per audio, or playlist
- Skin and Playlist skin
- Color palette and Custom colors
- Equalizer visualization
- Playlist heading: leave it empty to hide it
- Track information: Track title source, Subtitle (artist) field, Cover image field and style, Show a download link.
- Playback:
- Preload, Autoplay, Loop and Initial volume
- Rewind/forward step and Playback speeds
- Start in shuffle mode and Play the next track automatically
- Cross-origin (CORS) mode
- Behavior:
- Pause other players when one starts
- Remember the playback position
- Dock the playing player
- Keyboard shortcuts
- Lock screen and media key controls
Keyboard shortcuts (while the focus is inside a player)
- Space or K: play / pause
- ← or J, → or L: rewind / forward
- ↑ / ↓: volume
- M: mute
- N / P: next / previous track
- Home / End: start / end (on the progress bar)
Steps to create an audio playlist with Views
- Create a content type (for example Podcast episode) with an audio field: file, media or link. Optionally add a subtitle (artist) field and an image field for the cover. Add some content.
- Go to Structure → Views → Add view. Show Content of your type (or Media) and create a page or block.
- Add the fields: the audio field, and optionally the title, subtitle and image fields. Tick Exclude from display on fields you don't want shown twice.
- Under Format, choose Audio Player.
- In the format settings, map the fields:
- Audio source field (required): the audio field. In a view of media, the media ID or name also works.
- Title field: for example the content title. Leave it empty to use the file name.
- Subtitle (artist) field (optional).
- Thumbnail field (optional): an image field, shown for the playing track by playlist skin two.
- Choose the playlist skin, palette, equalizer and the other settings, then save the view.
- Open the view's page. Every result row is one track of the playlist.
Customization and theming
Templates. Every player uses audio-player.html.twig, which includes:
templates/includes/single-audio.html.twig: all single skins.templates/includes/audio-playlist.html.twig: both playlist skins.views-audio-player.html.twig: playlists from Views.
Copy a template into your theme's templates folder. Theme suggestions, from the most specific:
audio-player--ENTITY-TYPE--BUNDLE--FIELD-NAME.html.twigaudio-player--FIELD-NAME.html.twigaudio-player--ENTITY-TYPE--BUNDLE.html.twigaudio-player--ENTITY-TYPE.html.twigaudio-player--single--skin-one.html.twigoraudio-player--playlist--skin-two.html.twigaudio-player--single.html.twigoraudio-player--playlist.html.twigaudio-player--view--VIEW-ID.html.twig
Keep the audio-player-* class names on the controls; the player finds them by these classes.
Template variables.
audios: the tracks. Each hastitle,subtitle,url,download_url,cover_url,mime,filename,filesizeand theentity,mediaandfileobjects.- Also available:
skin,palette,audio_display,equalizer,settings,playback_ratesandattributes.
Colors. All colors are CSS custom properties, so your theme can define its own palette:
.my-palette { --single-audio-player-bg: #101820; --single-audio-primary-color: #fee715; --playlist-background: #101820; --playlist-accent-color: #fee715; }
See css/single-audio/color-palettes.css and css/audio-playlist/color-palettes.css for every property.
For developers.
$manager = \Drupal::service('audio_player.manager'); $track = $manager->buildFileTrack($file, ['subtitle' => 'Artist']); $build = $manager->build([$track], [ 'audio_display' => 'audio-playlist', 'playlist_skin' => 'skin-two', 'playlist_title' => 'Episodes', ]);
hook_audio_player_tracks_alter(): change titles, add artwork, remove tracks, or add data for templates, such as a Flag link per track ({{ audio.flag }}).hook_audio_player_build_alter(): change the render array of a field formatter.- JavaScript:
Drupal.AudioPlayer.playersholds every player on the page.- Every player has
play(),toggle(),seekBy(),setVolume()andtoggleMute(). - Playlists also have
next(),previous()andload().
- Every player has
See audio_player.api.php and the README for details.
Upgrade guide: 1.1.x to 1.2.0
1.2.0 needs no update steps. Existing field displays, views and template overrides keep their settings and keep working.
- Back up your database and code, and if possible test on a staging site first.
- Update the code:
composer require drupal/audio_player:^1.2 - Run updates and rebuild caches:
drush updb -y drush crThe site keeps working even before caches are rebuilt. Rebuilding loads the new player script and templates.
- Check your players on a few pages: single players, playlists and views.
- Try the new settings on the field's gear icon or the view's format settings. All new options are off, or keep the old behavior, until you change them.
What changes for visitors and site builders
- Titles: titles made from file names now keep capital letters, umlauts, accents and punctuation, where 1.1.x lowercased them and removed special characters.
- Colors: each skin now keeps its own default colors when several skins are on one page.
- Pausing: starting a player pauses the others, because "Pause other players" is on by default. Turn it off in the settings to keep the old behavior.
- Palette labels: the "Grey" palettes are labeled "Gray"; colors and machine names are unchanged.
For themers and developers
- Old template overrides keep working. If your theme or a base theme overrides
templates/single-audio/skin-*.html.twigortemplates/audio-playlist/skin-*.html.twig, those files are still used. For new work, overridetemplates/includes/*.html.twigor use a theme suggestion. Old templates can keep usingoriginal_url,audio_titleandaudio_subtitle. - The per-skin scripts were merged into
js/audio-player.js, and library names did not change. If you attached or overrode a per-skin script in your theme, check that player again. - CSS is now scoped to each skin. If your theme relied on a skin's styles leaking onto other elements, add those styles to your theme.
- The helper functions in
audio_player.module, such asaudio_player_single_audio_skins()andaudio_player_generate_name(), still work. New code should use theaudio_player.managerservice.
Staying on 1.1.x. 1.1.x remains available for sites that are not ready for 1.2.0:
composer require drupal/audio_player:~1.1.0
Troubleshooting and FAQ
- Only a file link shows, no player: check that the format is Audio Player (or Media Audio Player for media fields) on the display you are viewing, then rebuild caches.
- The player shows but nothing plays: open the browser console and network tab. A 404 means the file is missing on disk. A CORS error means the file needs CORS headers.
- Files on S3 or a CDN show 0:00 or don't play: add a CORS rule to the bucket that allows
GETandHEADfrom your site, or set Cross-origin (CORS) mode to None. With None, those files play but have no visualization. - My custom media type doesn't play: the media type must store a file with an audio MIME type. Remote and oEmbed media are not supported.
- Autoplay doesn't start: browsers block audio with sound until the visitor interacts with the page. The player waits for the first click.
- The equalizer is flat: it moves only while audio plays and needs access to the file (see CORS above).
- Keyboard shortcuts do nothing: they work while the focus is inside a player. Click a control or Tab into it first.
- My theme's styles change the player: use more specific rules in your theme, or define a palette class with the CSS custom properties.
- Can the audio keep playing on other pages? A normal page load stops audio. Turn on Remember the playback position and Dock the playing player so visitors can continue where they stopped. Uninterrupted playback across pages is tracked in #3561897.
The README has the full settings reference, more questions and answers, and theming details.
Recommended modules
- S3 File System: store audio files on Amazon S3. Set up CORS on the bucket.
- Flag: add like or favorite links to tracks with
hook_audio_player_tracks_alter().
Support
Please post bug reports, feature requests and support requests to the Audio Player issue queue. When reporting a problem, please include:
- your Drupal and module versions
- the field type and skin
- where the files are stored
- any errors from the browser console
Patches, merge requests and reviews are welcome.
Ask your assistant about Audio Player
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- field Drupal core
- file Drupal core
- image Drupal core
- media Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 1.2.0 | Stable | 10–11 | Nov 21, 2026 | ||
| 1.2.x-dev | Dev | 10–11 | Nov 21, 2026 | ||
| 1.1.4 | Stable | 10–11 | Sep 2, 2025 | ||
| 1.1.3 | Stable | 10–11 | Jul 29, 2025 | ||
| 1.1.2 | Stable | 10–11 | Jul 17, 2025 | ||
| 1.1.1 | Stable | 10–11 | Jul 12, 2025 | ||
| 1.1.0 | Stable | 10–11 | Jul 12, 2025 | ||
| 1.0.0 | Stable | 10–11 | Jul 9, 2025 | ||
| 1.0.x-dev | Dev | 10–11 | Jul 9, 2025 |