Version: 4.x
vime-embed
Embeds an external media player and enables interacting with it via postMessage. This is generally
used internally by other providers, but you could use it if your requirements are simple. You'll
also get the benefits of preconnections and lazy-loading. Refer to existing providers to
see what params you can pass in, how to send commands to the player, and how to listen to events.
Usage#
- HTML
- React
- Vue
- Svelte
- Stencil
- Angular
example.vue
example.html
example.ts
Properties#
| Property | Attribute | Description | Type | Default | 
|---|---|---|---|---|
| decoder | -- | A function which accepts the raw message received from the embedded media player via postMessageand converts it into a POJO. | ((data: string) => Record<string, any> ∣ undefined) ∣ undefined | undefined | 
| embedSrc | embed-src | A URL that will load the external player and media (Eg: https://www.youtube.com/embed/DyTCOwB0DVw). | string | '' | 
| mediaTitle | media-title | The title of the current media so it can be set on the inner iframefor screen readers. | string | '' | 
| origin | origin | Where the src request had originated from without any path information. | string ∣ undefined | undefined | 
| params | params | The parameters to pass to the embedded player which are appended to the embedSrcprop. These can be passed in as a query string or object. | string ∣ { [x: string]: any; } | '' | 
| preconnections | -- | A collection of URLs to that the browser should immediately start establishing a connection with. | string[] | [] | 
Events#
| Event | Description | Type | 
|---|---|---|
| vEmbedLoaded | Emitted when the embedded player and any new media has loaded. | CustomEvent<void> | 
| vEmbedMessage | Emitted when a new message is received from the embedded player via postMessage. | CustomEvent<any> | 
| vEmbedSrcChange | Emitted when the embedSrcorparamsprops change. The payload contains theparamsserialized into a query string and appended toembedSrc. | CustomEvent<string> | 
Methods#
postMessage(message: any, target?: string | undefined) => Promise<void>#
Posts a message to the embedded media player.
Returns#
Type: Promise<void>
Dependencies#
Used by#
Graph#
Built with StencilJS