Skip to content

VideoPress: add a playlist block - #51253

Open
heydemoura wants to merge 7 commits into
trunkfrom
vidp-370-add-a-videopress-playlist-block
Open

VideoPress: add a playlist block#51253
heydemoura wants to merge 7 commits into
trunkfrom
vidp-370-add-a-videopress-playlist-block

Conversation

@heydemoura

Copy link
Copy Markdown
Contributor

Proposed changes

Adds a lightweight videopress/playlist block to the VideoPress package (VIDP-370). The block stores a list of VideoPress video GUIDs and plays them in sequence.

  • Editor: build a playlist by pasting a VideoPress GUID or URL. Items can be reordered, removed, and given an optional display title; clicking an item previews it. Inspector toggles for "Autoplay next video" (default on) and "Loop playlist" (default off).
  • Frontend (server-rendered): the first video renders in an embed player above a clickable list of the playlist items. Clicking an item swaps the player to that video. When a video ends (the player posts videopress_ended from a trusted VideoPress origin), the view script advances to the next item, optionally looping back to the first.
  • Access rules: the block just embeds by GUID, so playback follows the videos' existing VideoPress privacy settings — the JWT token bridge is enqueued so private videos play for authorized, logged-in viewers, and restricting a playlist is done by restricting the page it lives on (e.g. logged-in users only), as requested in the issue.
  • Registered via 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.
  • Includes server-side render tests (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

  • Build the package: jp build packages/videopress
  • On a site with the standalone VideoPress plugin active (jp docker up -d + activate), edit a post and insert the VideoPress Playlist block.
  • Add two or more videos by GUID or VideoPress URL (e.g. https://videopress.com/v/xxxxxxxx). Reorder/remove items and set optional titles; confirm the preview switches when clicking an item's number.
  • Publish and view the post:
    • The first video should render with the item list below it.
    • Clicking an item should load and autoplay that video.
    • Letting a video play to the end should advance to the next one (with Autoplay next video on).
    • With Loop playlist enabled, the last video should hand back to the first.
  • Run jp test php packages/videopress — all tests should pass.

🤖 Generated with Claude Code

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>
@heydemoura
heydemoura requested a review from a team as a code owner August 13, 2026 16:16
@heydemoura heydemoura added the [Status] Needs Review This PR is ready for review. label Aug 13, 2026
@heydemoura heydemoura self-assigned this Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the vidp-370-add-a-videopress-playlist-block branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack vidp-370-add-a-videopress-playlist-block

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@jp-launch-control

jp-launch-control Bot commented Aug 13, 2026

Copy link
Copy Markdown

Code Coverage Summary

Cannot generate coverage summary while tests are failing. 🤐

Please fix the tests, or re-run the Code coverage job if it was something being flaky.

Full summary · PHP report · JS report

Heyde Moura and others added 6 commits August 13, 2026 13:42
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant