Repository source: docs/concepts/media_embed.md
Media embed
Purpose: Turn a recognized YouTube, Spotify, SoundCloud, Bandcamp or TikTok link in a post into one calm, playable object, without loading the provider until someone asks to play.
Scenario: A post holds a YouTube link. With FORUM_MEDIA_EMBEDS_ENABLED and FORUM_MEDIA_EMBEDS_INLINE_PLAYER_ENABLED on, it renders as one bar: a round play control with "Play", and the provider link ("YouTube ↗", labelled "Open on YouTube") at the bar's end. One tap opens the player under the bar and asks it to start (YouTube and TikTok autoplay=1, SoundCloud auto_play=true; Spotify and Bandcamp have no such setting). The bar then says Close. Opening a player by tap closes any other on the page, and closing a player clears its frame so it stops. With FORUM_MEDIA_EMBEDS_POSTERS_ENABLED also on, a closed YouTube player (not a Short) is its poster at 16:9 with the play control over it. The poster is copied once from YouTube's image host by a hidden background request on the first view, then served from this site, so page views never contact YouTube. On /tracks/ a closed player is a small tile beside the track's title (music section). The Music slides reuse the same player at full size and open it as if tapped when someone moves to the next slide, so the same start request goes out.
Sources: renderer (source unavailable), player script (source unavailable), poster store (source unavailable), poster request and route (source unavailable), styles (source unavailable) (.media-embed-player, .music-tracks), flags (source unavailable), tests (source unavailable), poster tests (source unavailable), browser check (source unavailable), plans, earlier embed work.
Boundary: no provider frame loads before a tap, and a page never fetches a poster while it renders. Posters live in a posters folder beside the preview cache database, not in the image store: they are a disposable cache, deleting them is safe, and a failed fetch waits an hour before the next try. A poster is answered from /internal/media-embeds/posters/<video id>.jpg with the one-year header attached images use. Without JavaScript the bar still opens the player, without autostart or closing others. Instagram keeps its preview card. Offline mode does not render embeds.
— Claude · 2026-11-27 UTC · Model: claude-opus-5-5 — Revised by Claude · 2026-11-29 UTC · Model: claude-opus-5-5 (slides as a caller)
Attached recordings use the same one-at-a-time rule: opening an embed pauses any audio attachment, and playing a recording closes an open embed.