Component
MediaEmbed
A YouTube or Vimeo video behind a click-to-load facade.
import { MediaEmbed } from '@loidolt/theme-svelte';
Example
Notes
- Nothing is requested from the provider until the user presses play, and then only from its no-tracking host (
youtube-nocookie.com, Vimeo withdnt=1). - No thumbnail is fetched from the provider by default, since that request alone would reveal the visit; pass a
posterof your own, orembedThumbnail()if the request is acceptable. - Once loaded, focus moves into the player so keyboard users carry on where the button was.
titlenames both the button and the iframe.
Props
Generated from the component source, so it cannot drift from the implementation.
| Prop | Type | Default | Notes |
|---|---|---|---|
title required | string | — | Required: names the iframe and the play button. |
class | string | — | |
eager | boolean | false | Load the provider's player straight away. By default a local facade stands in until the user presses play, so no third-party request happens before they choose to watch. |
playLabel | (title: string) => string | (name) => `Play ${name}` | |
poster | string | — | Still shown before the player loads. None is fetched from the provider by default — that request alone would tell them someone opened the page. |
privacy | boolean | true | No-tracking hosts: youtube-nocookie.com, Vimeo's dnt=1. |
provider | EmbedProvider | — | Or name the video directly. |
ratio | AspectRatioName | number | string | 'video' | |
ref bindable | HTMLDivElement | null | null | |
start | number | — | Start offset in seconds. Read from the URL when it carries one. |
unsupportedText | string | 'This video link is not supported.' | Shown when the URL is not a recognised YouTube or Vimeo link. |
url | string | — | A YouTube or Vimeo page, share or embed URL. |
videoId | string | — |
Plus the attributes of Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'>, forwarded to the root element.