tldraw/tldraw

Add an option to TldrawOptions to control whether videos autoplay

Open

#8.915 geöffnet am 21. Mai 2026

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (1 zugewiesene Person)TypeScript (47.037 Stars) (3.212 Forks)batch import
featuregood first issuesdk

Beschreibung

Problem

Today, video shapes autoplay by default. The behavior is configurable in two places:

  • Per shape, via TLVideoShape['props'].autoplay (set on the shape record itself).
  • As a default for newly created video shapes, via VideoShapeOptions.autoplay on VideoShapeUtil (see packages/tldraw/src/lib/shapes/video/VideoShapeUtil.tsx).

The shape-util option was added in #5716, but it can only be set by subclassing VideoShapeUtil. There is no way to disable video autoplay at the <Tldraw /> component level without writing a custom shape util — which is a lot of ceremony for a single boolean.

Proposed solution

Add a video autoplay option to TldrawOptions (packages/editor/src/lib/options.ts) so SDK consumers can do:

<Tldraw options={{ videoAutoplay: false }} />

The default should be true so current behavior is preserved. VideoShapeUtil should read this value when computing the autoplay default for new video shapes (or when deciding whether to set autoPlay on the rendered <video> element — the issue is which behavior we want; see below).

Naming suggestion: videoAutoplay, to match the existing shape.props.autoplay and VideoShapeOptions.autoplay and to leave room for a future audioAutoplay if needed.

Open questions

  • Should this option control the default autoplay prop on new video shapes, or whether any video plays automatically regardless of the shape's prop? The first matches the existing VideoShapeOptions.autoplay semantics; the second is a stronger guarantee that a host app can disable autoplay across the board, including for pasted/restored shapes.
  • Does it need to interact with the existing prefers-reduced-motion check at VideoShapeUtil.tsx:213? Probably not — that should keep behaving as it does today.

Alternatives considered

  • Subclassing VideoShapeUtil and overriding options.autoplay — works but is overkill for a single flag.
  • Setting shape.props.autoplay = false on every video at creation time — requires hooking into shape creation and doesn't help for pasted/loaded shapes.

Contributor Guide