Repository navigation
Conversation
- utilises new upstream waveform-is-placeholder class
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Intenzi! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Thanks for this fix @Intenzi - looks good to me. Can you resolve the merge conflicts and we can get this fix in? |
|
@jeryj 👋🏻 just doing some light triage and wondering if this fix is still required. Cheers! |
|
I believe @scruffian is familiar with this bug. Could you take a look? |
|
Gave this a test locally and it does what it says on the tin. One thing worth sorting out is the version bump, which trunk has already moved past. I had Claude set up the repro and run it both ways, here is what came back:
Can you merge trunk and drop the bump commit? I'm happy to re-test once that is in. |
|
I'm not very keen on this idea. I think if users choose bars then we should honour that choice, even if they aren't accurate. I think this will feel like a more broken experience. Instead, why don't we try saving the waveform data in the block? |
Thats a great idea, maybe we can try this.
Has the user chosen bars in this case? I understood it was caused by a CORS error when the Audio URL was on a remote server that didn't send CORS headers. Maybe @Intenzi can clarify. |
|
Thankyou for the response, I haven't been receiving any mails on this. I'll follow up with a response and required clarifications for the same by today. |
|
To answer @adamsilverstein 's question: Yes, when a user has chosen any playstyle (mirror/dots/etc.) for the track, it will revert to a flat seekbar to visibly display that the playlist block was unable to get the waveform for this track. I completely agree with @scruffian 's thought process. "If a user wants to display a dot pattern on their song, it should do that and not suddenly show a flat seekbar." is a very valid concern. There are two technical limitations to why I have not approached storing the waveform into the block locally or in a database:-
export async function generateWaveform(url, samples = DEFAULT_SAMPLES, shouldDetectBPM = false) {
let audioContext;
try {
const AudioCtx = window.AudioContext || window.webkitAudioContext;
audioContext = new AudioCtx();
const response = await fetch(url);
const arrayBuffer = await response.arrayBuffer();
const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
let peaks = extractPeaks(audioBuffer, samples);
...
b> If we decide to save the waveform data somehow (which is by default an array of 1800 float values per track) into the post content, it will lead to a much larger initial payload size when anyone requests for a page with multiple tracks in the playlist block.
I looked a bit further, as an industrial precedent : SoundCloud also follows the UX of falling back to a flat seekbar when no metadata could be obtained/waveform couldn't be analysed. I am open to any clarifications and suggestions, improvements we can utilise to make the experience better for the end user. Please comment if any further questions arise for the PR and the topic. |
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the |
|
👋 @scruffian I've gone through the PR #83086 , I think its a good optimisation towards caching waveforms. Great work there! I understand that it avoids having to download and decode the full audio file on the front end everytime just to generate the waveform. I just went through #84712 and I think it makes sense if we can move the saving of the waveform to the database separately as attachment metadata, as proposed there. Would you be willing to look into that approach? I think it's a great middle ground that avoids post bloat and keeps the data reusable across other blocks. Regardless, the solution in this PR is separate and complimentary :) It targets scenarios where an audio file is missing, deleted or blocked by CORS. Ensuring it cleanly falls back to a flat seekbar rather than a fake waveform. This fallback can be used as the safety net to build further on top the optimisation PR you are working towards 😄 . |



What?
Closes #80534 (Follow-up to Trac #65673 and #80533 )
Associated Upstream Issue: arraypress/waveform-player#19
Associated Upstream PR: arraypress/waveform-player#20
@arraypress/waveform-playertov1.24.0: Pulls in the upstream release that adds thewaveform-is-placeholderclass to the player container when audio analysis fails (e.g., due to CORS or network errors).seekbarvisualization.Why?
Referring from issue #80534 :
The waveform visualization for such tracks is however still affected. Since the audio file needs to be fetched via
fetch()for generating a waveform, if the audio file's src is a third party such as Amazon S3.. that fetch is blocked by CORS policy. The waveform library would then silently fallback to randomly generated placeholder peaks for the audio track. The user would see a waveform that looks very realistic but has no relationship to the actual audio. Which is considered bad/misleading UX.How?
waveform-is-placeholderclass to the player's container element when the track could not be fetched for waveform analysis.Inside
gutenberg/packages/block-library/utils/waveform-utils.js:onLoadcallback to check if thewaveform-is-placeholderclass is present on the player's container.seekbarstyle for when the waveform generated is a random placeholder.Testing Instructions
Here are the formatted Testing Instructions you can copy directly into your PR description:
Testing Instructions
.mp3audio file..mp3file to add it as a track."src"to a third-party audio URL lacking CORS headers (e.g.https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3) and change its"id" value..mp3file again as a second track in the playlist (so the playlist now contains: Track 1 = External CORS-blocked, Track 2 = Local).Testing Instructions for Keyboard
N/A
Screenshots or screencast
Demonstrates automatic waveform style change for same playlist block with different tracks:
8mb.video-Fix.Playlist.Waveform.Gutenberg.mp4
Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity IDE
Model(s): Gemini 3.1 Pro (High)
Used for: Help in identifying the possible implementations and deciding on an optimal resolution. Final implementation was reviewed and tested by me.