Skip to content

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,
  },
});
OptionTypeDescription
autoPlaybooleanStart playing automatically
showControlsbooleanShow playback controls (default true)
loopbooleanLoop playback
mutebooleanMute audio
startnumberStart offset in ms
endnumberEnd offset in ms
rewindbooleanRewind after playing
fullscreenbooleanPlay 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

TypeContent Types
Videovideo/mp4, video/webm, video/avi
Audioaudio/mpeg, audio/mp3, audio/wav, audio/ogg

Options Reference

OptionTypeDescription
x, ynumberPosition in inches
w, hnumberSize in inches
pathstringFile path
dataUint8ArrayRaw media data
contentTypestringMIME type
posterMediaPosterPreview thumbnail
playbackMediaPlaybackOptionsPlayback behavior

Provide either path or data + contentType.

See MediaOptions for the full reference.

Released under the MIT License.