Media
Embed video and audio files in slides.
Video
From a file path:
typescript
slide.addVideo({
path: './intro.mp4',
x: 1, y: 1, w: 6, h: 4,
});From a buffer:
typescript
import { readFileSync } from 'node:fs';
slide.addVideo({
data: readFileSync('./video.mp4'),
contentType: 'video/mp4',
x: 1, y: 1, w: 6, h: 4,
});Audio
typescript
slide.addAudio({
path: './narration.mp3',
x: 0.5, y: 0.5, w: 1, h: 1,
});Playback Options
typescript
slide.addVideo({
path: './demo.mp4',
x: 1, y: 1, w: 6, h: 4,
playback: {
autoPlay: true,
showControls: true,
loop: false,
mute: false,
start: 5000,
end: 30000,
},
});| Option | Type | Description |
|---|---|---|
autoPlay | boolean | Start playing automatically |
showControls | boolean | Show playback controls (default true) |
loop | boolean | Loop playback |
mute | boolean | Mute audio |
start | number | Start offset in ms |
end | number | End offset in ms |
rewind | boolean | Rewind after playing |
fullscreen | boolean | Play in fullscreen |
Poster Thumbnail
Set a preview image shown before playback:
typescript
slide.addVideo({
path: './demo.mp4',
x: 1, y: 1, w: 6, h: 4,
poster: { path: './thumbnail.png' },
});Supported Formats
| Type | Content Types |
|---|---|
| Video | video/mp4, video/webm, video/avi |
| Audio | audio/mpeg, audio/mp3, audio/wav, audio/ogg |
Options Reference
| Option | Type | Description |
|---|---|---|
x, y | number | Position in inches |
w, h | number | Size in inches |
path | string | File path |
data | Uint8Array | Raw media data |
contentType | string | MIME type |
poster | MediaPoster | Preview thumbnail |
playback | MediaPlaybackOptions | Playback behavior |
Provide either path or data + contentType.
See MediaOptions for the full reference.