Media enables the addition of audio, video and online video to Slides.
// Path: full or relative
slide.addMedia({ type: "video", path: "https://example.com/media/sample.mov" });
slide.addMedia({ type: "video", path: "../media/sample.mov" });
// Base64: pre-encoded string
slide.addMedia({ type: "audio", data: "audio/mp3;base64,iVtDafDrBF[...]=" });
// YouTube: Online video (supported in Microsoft 365)
slide.addMedia({ type: "online", link: "https://www.youtube.com/embed/Dph6ynRVyUc" });
Either provide a URL location or base64 data along with type to create media.
type
- type: media typepath
- URL: relative or fulldata
- base64: string representing an encoded imageOption | Type | Default | Description | Possible Values |
---|---|---|---|---|
x |
number | 1.0 |
hor location (inches) | 0-n |
x |
string | hor location (percent) | ‘n%’. (Ex: {x:'50%'} middle of the Slide) |
|
y |
number | 1.0 |
ver location (inches) | 0-n |
y |
string | ver location (percent) | ‘n%’. (Ex: {y:'50%'} middle of the Slide) |
|
w |
number | 1.0 |
width (inches) | 0-n |
w |
string | width (percent) | ‘n%’. (Ex: {w:'50%'} 50% the Slide width) |
|
h |
number | 1.0 |
height (inches) | 0-n |
h |
string | height (percent) | ‘n%’. (Ex: {h:'50%'} 50% the Slide height) |
Option | Type | Description | Possible Values |
---|---|---|---|
data |
string | image data (base64) | (data or path is required) base64-encoded image string. |
path |
string | image path | (data or path is required) relative or full URL |
Option | Type | Description | Possible Values |
---|---|---|---|
type |
string | media type | media type: audio or video (reqs: data or path ) or online (reqs:link ) |
cover |
string | cover image | base64 encoded string of cover image |
extn |
string | media extension | use when the media file path does not already have an extension, ex: “/folder/SomeSong” |
link |
string | video URL | (YouTube only): link to online video |
Sample code: demos/modules/demo_media.mjs