fix: load videos in Media Gen preview on mobile (muted autoplay + poster)#487
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes mobile “black box” video previews in Media Gen by updating <video> elements to use the standard muted-autoplay + poster pattern so iOS/Android will actually start playback (or at least render a visible thumbnail immediately).
Changes:
- Add
muted,poster, andpreload="metadata"to the MediaLightbox video element. - Apply the same
muted+posterbehavior to the Video Gen inline result preview. - Add a new regression test to pin the MediaLightbox
<video>markup contract (including omittingposterwhen no thumbnail exists).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| client/src/components/media/MediaLightbox.jsx | Updates the lightbox <video> to be mobile-autoplay compatible and to render a thumbnail immediately via poster. |
| client/src/pages/VideoGen.jsx | Updates the inline preview <video> to autoplay muted on mobile and show a thumbnail via poster. |
| client/src/components/media/MediaLightbox.test.jsx | Adds regression coverage ensuring the lightbox <video> includes the required attributes and omits poster when absent. |
| .changelog/NEXT.md | Documents the mobile preview fix in the vNEXT changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
Videos from the Media Gen pages didn't load in the preview modal on mobile — the area showed only a black box.
Root cause
The lightbox
<video>(and the Video Gen page's inline result preview) usedautoPlaywithoutmutedand without aposter. Mobile browsers (iOS Safari especially, also Chrome Android) block unmuted autoplay that isn't triggered inside a direct user gesture. Opening the modal is a tap, butplay()happens during render — so the clip never starts, and with noposterthe element paints nothing until playback begins. The result reads as "not loading."Images were unaffected because they render a small always-visible
<img>thumbnail. Server-sideexpress.staticalready setsacceptRanges: true, so this was never a Range/serving problem — it's purely the video element's mobile autoplay/poster behavior.Fix
For both video surfaces on the Media Gen pages:
muted— makes autoplay eligible under the mobile media-engagement policy (iOS/Android).controlsstays so the user can unmute.poster— paints the thumbnail immediately, so there's a visible frame even while the clip buffers (and as a fallback if playback is deferred). The lightbox usesitem.previewUrl; the Video Gen inline preview usesresult.thumbnail.preload="metadata"— ensures the first frame/metadata loads (also already present on the inline preview).This is the conventional muted-autoplay preview pattern. The one behavior change on desktop is that the clip now autoplays muted instead of with sound — intentional and gentler; controls allow unmuting.
Files
client/src/components/media/MediaLightbox.jsx— preview-modal<video>getsmuted+poster.client/src/pages/VideoGen.jsx— inline result preview gets the same fix.client/src/components/media/MediaLightbox.test.jsx— new regression test pinning the<video>contract (poster,muted,playsInline,loop,controls,src), plus poster-omitted-when-no-thumbnail.Testing