Skip to content

Playlist Block: Add waveform playback controls - #75060

Open
scruffian wants to merge 70 commits into
trunkfrom
try/waveformplayer
Open

scruffian wants to merge 70 commits into
trunkfrom
try/waveformplayer

Conversation

@scruffian

@scruffian scruffian commented Jan 29, 2026 •

Copy link
Copy Markdown
Contributor

What?

This PR extends the Playlist block's waveform player with:

  • Playlist navigation controls for previous track, next track, shuffle, and repeat.
  • Repeat modes that cycle from off, to repeat playlist, to repeat current track.
  • Repeat playlist behavior that advances to the next track that would play, including shuffled playback.
  • Repeat current track behavior that replays the active track when a track ends or when next is pressed.
  • Separate icons for repeat playlist and repeat current track, without the numeric repeat-one overlay.
  • A Tracklist setting for showing or hiding track lengths.
  • Hover styling for the waveform bars and refreshed playlist track styling.
  • Shared waveform helpers for time formatting, control setup, hover behavior, repeat/shuffle playback decisions, and cleanup.

It also updates the Playlist block attributes documentation and adds unit coverage for the new playlist and waveform utility behavior.

Why?

The Playlist block already uses a waveform player, but the player and track list need more of the controls and display options users expect from a playlist experience. These changes make it easier to navigate between tracks, randomize playback, repeat either the playlist or current track, and simplify the visible track metadata.

How?

  • Adds showTrackLength, showProgressBackground, and progressColor Playlist block attributes.
  • Passes the existing selected visualization style from the block style class into the editor and frontend waveform player.
  • Adds previous, next, shuffle, and repeat callbacks in both the editor component and frontend Interactivity API view.
  • Adds shared waveform utility support for formatting time, setting up playlist controls, applying hover colors, choosing repeat/shuffle playback actions, replaying the current track, and cleaning up listeners.
  • Adds repeat button state labels and mode-specific icons for repeat playlist and repeat current track.
  • Adds playlist track list classes and styles for hiding track lengths and improving active/hover track states.
  • Aligns focus styling across the custom waveform play and playlist control buttons.

Screenshots

Screenshot 2026-06-05 at 13 10 09

Testing Instructions

  1. Start the test environment if needed with npm run wp-env-test status and npm run wp-env-test start.
  2. Build or run the editor assets.
  3. Add a Playlist block with multiple audio tracks.
  4. Confirm the waveform player appears and playback works.
  5. Use previous and next controls to move between tracks.
  6. Enable shuffle and confirm next/ended playback selects another track.
  7. Enable repeat playlist and confirm ended/next playback advances to the next track that would play, wrapping as needed.
  8. Enable repeat current track and confirm ended/next playback replays the current track.
  9. Enable shuffle and repeat current track together and confirm ended/next playback still replays the current track.
  10. Switch between the existing waveform block styles and confirm the visualization still updates.
  11. Toggle the Tracklist track length setting and confirm durations hide/show.
  12. Confirm track hover and active states render correctly in the editor and frontend.

Automated Tests

  • npm run test:unit packages/block-library/src/utils/test/waveform-utils.js packages/block-library/src/utils/test/waveform-player.js -- --runInBand
  • npm run test:unit packages/block-library/src/playlist/test/edit.js -- --runInBand
  • npm run lint:js -- packages/block-library/src/utils/waveform-utils.js packages/block-library/src/utils/waveform-player.js packages/block-library/src/utils/test/waveform-utils.js packages/block-library/src/utils/test/waveform-player.js packages/block-library/src/playlist/edit.js packages/block-library/src/playlist/view.js
  • npm run lint:css -- packages/block-library/src/playlist/style.scss
  • git diff --check

@scruffian scruffian self-assigned this Jan 29, 2026
@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Jan 29, 2026
@github-actions

github-actions Bot commented Jan 29, 2026 •

Copy link
Copy Markdown

Size Change: +8.8 kB (+0.11%)

Total Size: 7.73 MB

📦 View Changed
Filename Size Change
build/modules/block-library/playlist/view.min.js 19.2 kB +2.38 kB (+14.18%) ⚠️
build/scripts/block-library/index.min.js 353 kB +2.42 kB (+0.69%)
build/styles/block-library/editor-rtl.css 12.7 kB +47 B (+0.37%)
build/styles/block-library/editor-rtl.min.css 10.4 kB +45 B (+0.44%)
build/styles/block-library/editor.css 12.7 kB +47 B (+0.37%)
build/styles/block-library/editor.min.css 10.4 kB +46 B (+0.45%)
build/styles/block-library/playlist-track/style-rtl.css 927 B +399 B (+75.57%) 🆘
build/styles/block-library/playlist-track/style-rtl.min.css 519 B +25 B (+5.06%) 🔍
build/styles/block-library/playlist-track/style.css 926 B +397 B (+75.05%) 🆘
build/styles/block-library/playlist-track/style.min.css 518 B +25 B (+5.07%) 🔍
build/styles/block-library/playlist/editor-rtl.css 209 B +103 B (+97.17%) 🆘
build/styles/block-library/playlist/editor-rtl.min.css 189 B +95 B (+101.06%) 🆘
build/styles/block-library/playlist/editor.css 209 B +103 B (+97.17%) 🆘
build/styles/block-library/playlist/editor.min.css 189 B +95 B (+101.06%) 🆘
build/styles/block-library/playlist/style-rtl.css 2.5 kB +352 B (+16.35%) ⚠️
build/styles/block-library/playlist/style-rtl.min.css 2.41 kB +340 B (+16.45%) ⚠️
build/styles/block-library/playlist/style.css 2.51 kB +354 B (+16.43%) ⚠️
build/styles/block-library/playlist/style.min.css 2.41 kB +342 B (+16.54%) ⚠️
build/styles/block-library/style-rtl.css 22.6 kB +306 B (+1.37%)
build/styles/block-library/style-rtl.min.css 19.1 kB +286 B (+1.52%)
build/styles/block-library/style.css 22.7 kB +305 B (+1.36%)
build/styles/block-library/style.min.css 19.1 kB +285 B (+1.52%)

compressed-size-action

@github-actions

github-actions Bot commented Jan 29, 2026 •

Copy link
Copy Markdown

Flaky tests detected in 5d869fe.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29352899087
📝 Reported issues:

@scruffian scruffian mentioned this pull request Feb 3, 2026
@scruffian
scruffian force-pushed the try/waveformplayer branch 2 times, most recently from 06722cc to 219fcef Compare February 3, 2026 10:21
@scruffian scruffian changed the title try waveformplayer Playlist Block: Add WaveformPlayer visualization Feb 4, 2026
@scruffian scruffian added [Type] Enhancement A suggestion for improvement. [Block] Playlist labels Feb 4, 2026
@scruffian
scruffian force-pushed the try/waveformplayer branch 2 times, most recently from cc09ee2 to cb693c9 Compare February 4, 2026 14:54
@scruffian
scruffian force-pushed the try/waveformplayer branch 3 times, most recently from 9502f73 to 4a2abf1 Compare February 13, 2026 14:15
@scruffian
scruffian changed the base branch from trunk to try/waveformplayer-simple February 13, 2026 14:17
@scruffian
scruffian changed the base branch from try/waveformplayer-simple to trunk February 13, 2026 14:18
@scruffian
scruffian changed the base branch from trunk to try/waveformplayer-simple February 13, 2026 14:22
@scruffian
scruffian force-pushed the try/waveformplayer branch 3 times, most recently from 19c142f to 97d95c0 Compare February 13, 2026 15:14
@scruffian scruffian changed the title Playlist Block: Add WaveformPlayer visualization Playlist Block: Add more WaveformPlayer options Feb 13, 2026
@scruffian
scruffian force-pushed the try/waveformplayer-simple branch 2 times, most recently from 997086d to 7deb4ae Compare February 19, 2026 12:19
@scruffian
scruffian force-pushed the try/waveformplayer-simple branch 3 times, most recently from fac2ce5 to d31f330 Compare February 26, 2026 11:11
scruffian and others added 29 commits July 15, 2026 11:37
Replace the createSvgIcon() DOM builder with inline SVG markup strings
set via innerHTML on each control button. Simpler for static icons, and
still iframe-safe (the button is created in the container's document, so
innerHTML parses there). Verified the markup yields a queryable svg path
so styleSvgIcons and the active-state fill still apply.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The shuffle and repeat controls are toggle buttons but only conveyed
their on/off state visually via an is-active class, leaving it
inaccessible to assistive technology.

Make aria-pressed the single source of truth: set it from the initial
shuffle/repeat state, flip it in the click handlers, and key the
toggled-on styling off [aria-pressed="true"] instead of .is-active.
Drop the is-active class entirely. Prev/next stay momentary actions
with no aria-pressed.

Export setupPlaylistControls and add unit tests covering the initial
state, the prev/next absence of aria-pressed, and the toggle behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The play button kept focus via a requestAnimationFrame refocus that let
the library's container steal focus and then grabbed it back. Match the
prev/shuffle/repeat/next controls instead: add a click listener that
calls stopPropagation so the click never reaches the container's
self-focus handler. stopPropagation (not stopImmediatePropagation)
leaves the library's own togglePlay handler on the same element intact.

Add unit tests asserting a play button click does not bubble to the
container, and that cleanup removes the listener.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Tested in the editor: keyboard focus on the skip controls survives a
track change without the restore machinery, so the restoreFocusRef /
focusControl path is unnecessary. Remove it from both the editor
component and initWaveformPlayer.

Focus on every control (play/pause, prev, shuffle, repeat, next) is now
preserved by a single mechanism: stopPropagation on each button's click
so the library's container never steals focus.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@scruffian
scruffian force-pushed the try/waveformplayer branch from 5d869fe to 56fdb7e Compare July 15, 2026 10:38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Playlist [Package] Block library /packages/block-library [Package] Icons /packages/icons [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants