Skip to main content

Module video

Module video 

Source
Expand description

Video embed synthesizer.

Receives a TitleParams (Stage 2 dispatcher already parsed it), the source URL, and an AssetSnapshot. Emits final <video> HTML at the typed-data boundary — including every attribute the legacy add_video_placeholder_attributes regex used to inject.

§Authoritative byte shape (Phase 2E parity)

<video class="moss-embed moss-embed-video" src="URL.mp4"
       data-placeholder-src="URL.original" poster="URL.thumb.jpg"
       data-thumb-src="URL.thumb.jpg" controls preload="metadata"
       { width="W"}?{ height="H"}?></video>
  • Single src= attribute on <video> (no nested <source> child) — load-bearing for the surviving add_video_placeholder_attributes regex pass (preserved until PR3 of Phase 2E). The regex’s skip guard at placeholder.rs:435 triggers on data-placeholder-src, making the post-pass a no-op for synthesizer-emitted videos. Source: moss-core pre-Phase-0 VideoRenderer at crates/moss-core/src/resolve/embed_renderer.rs:509-571 (commit efb834a3e).
  • controls preload="metadata" emitted on the default branch. The ambient loop branch (![[clip.mp4|loop]]) instead emits autoplay muted loop playsinline preload="metadata" with no controls and adds data-loop for JS/CSS targeting. See AMBIENT_PLAYBACK_ATTRS.
  • Width/height priority: (1) TitleParams |WxH sizing alias wins when present (with units like 640px). (2) AssetSnapshot.dimensions lookup as fallback, emitted unitless (e.g. width="1920"). (3) Both attributes omitted when the snapshot dims are (0, 0) — that is the sentinel for “unknown,” NOT a real dimension. Both omitted when no entry is in the snapshot.
  • data-placeholder-src is the ORIGINAL src (e.g. clip.mov). The iframe-bridge swaps src to the .mp4 payload once the transcode completes (frontend/bridge/iframe-bridge.ts:666).
  • poster and data-thumb-src both reference to_thumb(original_src). The iframe-bridge listens for moss-thumb-ready and swaps poster in when the thumbnail lands.

§.mov.mp4 source-extension swap (moved from placeholder.rs)

moss converts .mov source files to .mp4 during build, so a raw .mov reference in the rendered HTML would 404. Pre-Phase-0 this swap lived in placeholder.rs::add_video_placeholder_attributes as a regex post-pass. Phase 1’s typed-data-boundary architecture moves it here: the synthesizer is the single source of truth for the URL that ends up in <video src=>.

§Multi-source HLS form (NOT emitted here)

This synthesizer never emits <video><source src=…></video> (multi- source / adaptive-bitrate form). That shape is reserved for HLS / DASH streams that don’t need transcode-pending hydration. The regex pass also skips it (video_re requires src="…" directly on <video>), and the data-placeholder-src / poster / data-thumb-src injection only applies to the single-src form by design. If a future callsite wants the multi-source form, it must NOT route through this synthesizer.

Constants§

AMBIENT_PLAYBACK_ATTRS
Core playback attributes shared by the ambient loop branch and cover.rs.

Functions§

synthesize_video_html
Synthesize video embed HTML for Tag::Link with moss:kind=video title.