VideoPress: add a playlist block - #51253
Open
heydemoura wants to merge 7 commits into
Open
Conversation
Add a lightweight videopress/playlist block that stores a list of VideoPress video GUIDs and plays them in sequence. The editor manages the GUID list (add by GUID or URL, reorder, remove, optional titles); the frontend renders the first video with a clickable item list, and the view script advances to the next video when the player posts videopress_ended, with optional looping. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCannot generate coverage summary while tests are failing. 🤐 Please fix the tests, or re-run the Code coverage job if it was something being flaky. |
Covers the code-coverage CI requirement: jest tests for the view script (item clicks, videopress_ended advance, origin checks, loop, multiple playlists) and the editor component (add/remove/reorder, input validation, settings toggles), plus registration tests for register_videopress_playlist_block() via a block.json fixture and the non-array/missing-guid render branches. The registration method now accepts an optional metadata path so tests don't depend on build artifacts, and view.ts exports its init functions for testing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds a 'Choose from library' button (MediaUpload, multiple selection) next to the GUID/URL input, so playlists can be built from the site's VideoPress videos. Library picks map attachments to GUIDs via videopress_guid and use the attachment title as the item title; selections with no VideoPress videos surface an error notice, shared with the GUID/URL validation path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Item titles in the playlist block editor are no longer editable text fields. Titles come from the video's own data: library selections keep the attachment title, and entries added by GUID or URL fetch the title from the VideoPress API, falling back to the GUID label when the video data isn't reachable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adding by URL/GUID previously relied only on an async backfill, so a failed fetch left the GUID as the visible label. The add action now awaits the video data and stores the title with the entry (busy state on the button while fetching), matching library selections. The backfill effect remains as a safety net for entries whose fetch failed and for playlists saved before titles were stored. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Titles now always reflect the videos' current metadata. In the editor, every entry is refreshed from the VideoPress API once per session and the stored title is replaced when it differs. On the frontend, the render callback pulls the current title from the public VideoPress API (transient-cached for an hour, with brief negative caching on failure) and falls back to the stored title when the API has no usable answer, e.g. for private videos. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The identical back-to-back render is the point of the test: the second call must be served from the transient cache. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Adds a lightweight
videopress/playlistblock to the VideoPress package (VIDP-370). The block stores a list of VideoPress video GUIDs and plays them in sequence.videopress_endedfrom a trusted VideoPress origin), the view script advances to the next item, optionally looping back to the first.Initializer::register_videopress_blocks(), so it ships wherever the VideoPress package blocks are registered (standalone VideoPress plugin). Exposing it through the Jetpack plugin's extension list can follow up separately.Playlist_Block_Test) covering markup, GUID validation, escaping, and the auto-advance/loop data attributes.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
jp build packages/videopressjp docker up -d+ activate), edit a post and insert the VideoPress Playlist block.https://videopress.com/v/xxxxxxxx). Reorder/remove items and set optional titles; confirm the preview switches when clicking an item's number.jp test php packages/videopress— all tests should pass.🤖 Generated with Claude Code