[pull] main from tldraw:main#563
Merged
Merged
Conversation
In order to let SDK consumers disable video autoplay across the board
without subclassing `VideoShapeUtil`, this PR adds a top-level
`allowVideoAutoplay` option to `TldrawOptions`. The host opt-out acts as
a ceiling, not a floor: when `false`, no video autoplays regardless of
its per-shape `autoplay` prop; when `true` (the default, preserving
existing behavior), each shape's per-shape `autoplay` prop is respected.
The `prefers-reduced-motion` check at the render site continues to apply
independently.
```tsx
<Tldraw options={{ allowVideoAutoplay: false }} />
```
### Behavior matrix
| `TldrawOptions.allowVideoAutoplay` | `shape.props.autoplay` | Result |
| ---------------------------------- | ---------------------- |
--------------- |
| `true` (default) | `true` | Autoplays |
| `true` (default) | `false` | Does not play |
| `false` | `true` | Does not play |
| `false` | `false` | Does not play |
So `allowVideoAutoplay: false` is a global opt-out for the host app — it
never forces every video to play. The per-shape prop remains the way
users opt individual shapes in or out when autoplay is allowed at the
host level.
Closes [#8915](#8915).
### Change type
- [x] \`feature\`
### Test plan
1. Create a tldraw editor with \`<Tldraw options={{ allowVideoAutoplay:
false }} />\`.
2. Drop a video file onto the canvas — confirm it does not start playing
automatically.
3. Click into the video to edit, press play — confirm the user can still
play it manually.
4. With the default option (or \`allowVideoAutoplay: true\`), drop a
video and confirm it still autoplays as before.
5. With the default option, set \`shape.props.autoplay = false\` on an
individual video — confirm only that shape stops autoplaying while
others still autoplay.
### Release notes
- Add an \`allowVideoAutoplay\` option to \`TldrawOptions\`. When set to
\`false\`, no video shape autoplays regardless of its per-shape
\`autoplay\` prop — including pasted and restored shapes. Defaults to
\`true\`.
### API changes
- Added \`TldrawOptions.allowVideoAutoplay: boolean\` (default
\`true\`).
### Code changes
| Section | LOC change |
| --------------- | ---------- |
| Core code | +18 / -1 |
| Automated files | +2 / -0 |
| Documentation | +7 / -0 |
---------
Co-authored-by: Max Drake <maxdrake46@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )