|
| 1 | +--- |
| 2 | +title: Minimal video player |
| 3 | +description: Use MinimalVideoPlayer for muted, looping product demonstrations with a single play and pause control |
| 4 | +keywords: ['playback', 'media', 'video', 'motion'] |
| 5 | +show-tabs: false |
| 6 | +ready: true |
| 7 | +source: https://github.com/primer/brand/blob/main/packages/react/src/MinimalVideoPlayer/MinimalVideoPlayer.tsx |
| 8 | +storybook: '/brand/storybook/?path=/story/components-minimalvideoplayer--playground' |
| 9 | +thumbnail: '/images/thumbnails/minimal-video-player-thumbnail.png' |
| 10 | +thumbnail_darkMode: '/images/thumbnails/minimal-video-player-thumbnail-dark.png' |
| 11 | +--- |
| 12 | + |
| 13 | +```js |
| 14 | +import {MinimalVideoPlayer} from '@primer/react-brand' |
| 15 | +``` |
| 16 | + |
| 17 | +Use `MinimalVideoPlayer` for short, silent product demonstrations that need only a play and pause control. |
| 18 | + |
| 19 | +Use [VideoPlayer](/components/VideoPlayer) when viewers need audio, captions, seeking, volume, fullscreen controls, |
| 20 | +branding, or a dedicated programmatic playback API. |
| 21 | + |
| 22 | +## Examples |
| 23 | + |
| 24 | +### Default |
| 25 | + |
| 26 | +Pass a native video URL with `src`. The required `title` provides a concise accessible name for the video. |
| 27 | + |
| 28 | +```jsx live |
| 29 | +<MinimalVideoPlayer |
| 30 | + aria-describedby="product-demo-description" |
| 31 | + poster="/images/example-poster.png" |
| 32 | + src="/example.mp4" |
| 33 | + title="Product interface demonstration" |
| 34 | +/> |
| 35 | +``` |
| 36 | + |
| 37 | +### Native source element |
| 38 | + |
| 39 | +The component also accepts native `<source>` children. |
| 40 | + |
| 41 | +```jsx live |
| 42 | +<MinimalVideoPlayer poster="/images/example-poster.png" title="Product interface demonstration"> |
| 43 | + <source src="/example.mp4" type="video/mp4" /> |
| 44 | +</MinimalVideoPlayer> |
| 45 | +``` |
| 46 | + |
| 47 | +### Disable automatic playback |
| 48 | + |
| 49 | +`autoPlay` defaults to `true`, making the video eligible to play when it enters the viewport. Set it to `false` when playback should always begin with an explicit user action. |
| 50 | + |
| 51 | +```jsx live |
| 52 | +<MinimalVideoPlayer |
| 53 | + autoPlay={false} |
| 54 | + poster="/images/example-poster.png" |
| 55 | + src="/example.mp4" |
| 56 | + title="Product interface demonstration" |
| 57 | +/> |
| 58 | +``` |
| 59 | + |
| 60 | +### Disable looping |
| 61 | + |
| 62 | +Videos loop by default. Set `loop` to `false` when the demonstration should stop after one playback. |
| 63 | + |
| 64 | +```jsx live |
| 65 | +<MinimalVideoPlayer |
| 66 | + loop={false} |
| 67 | + poster="/images/example-poster.png" |
| 68 | + src="/example.mp4" |
| 69 | + title="Product interface demonstration" |
| 70 | +/> |
| 71 | +``` |
| 72 | + |
| 73 | +### Customize control labels |
| 74 | + |
| 75 | +Provide localized play and pause labels with `internalAccessibleLabels`. Keep `title` focused on naming the video rather than the control. |
| 76 | + |
| 77 | +```jsx live |
| 78 | +<MinimalVideoPlayer |
| 79 | + autoPlay={false} |
| 80 | + internalAccessibleLabels={{ |
| 81 | + play: 'Play product demonstration', |
| 82 | + pause: 'Pause product demonstration', |
| 83 | + }} |
| 84 | + poster="/images/example-poster.png" |
| 85 | + src="/example.mp4" |
| 86 | + title="Product interface demonstration" |
| 87 | +/> |
| 88 | +``` |
| 89 | + |
| 90 | +## Playback behavior |
| 91 | + |
| 92 | +`MinimalVideoPlayer` is always muted, plays inline, and hides native controls. When `autoPlay` is enabled, it starts only while visible, pauses after leaving the viewport, and resumes after re-entering the viewport unless the viewer paused it manually. |
| 93 | + |
| 94 | +The forwarded ref provides access to the underlying `<video>` element, but the component does not provide a higher-level programmatic playback API. |
| 95 | + |
| 96 | +The component respects the viewer's reduced-motion preference. It suppresses initial automatic playback when reduced motion is requested and pauses playback if that preference becomes active. A viewer can still start the video with the visible play control. |
| 97 | + |
| 98 | +## Accessibility |
| 99 | + |
| 100 | +The `title` prop provides an accessible name for the video. It does not replace a text alternative for meaningful visual content. |
| 101 | + |
| 102 | +For decorative motion or a demonstration that repeats information already communicated by the surrounding content, use a concise `title`. A separate description is not required because the same information is already available on the page. |
| 103 | + |
| 104 | +For a meaningful silent demonstration, provide adjacent text that communicates the important actions and outcomes shown in the video. Associate that text with the video using the native `aria-describedby` attribute, as shown in the [default example](#default). |
| 105 | + |
| 106 | +Use [VideoPlayer](/components/VideoPlayer) instead when the media needs audio, captions, seeking, volume, fullscreen controls, or a standalone viewing experience. |
| 107 | + |
| 108 | +## Component props |
| 109 | + |
| 110 | +`MinimalVideoPlayer` supports standard native `<video>` attributes except the playback attributes controlled by the component. |
| 111 | + |
| 112 | +| Name | Type | Default | Required | Description | |
| 113 | +| :------------------------- | :------------------------------ | :------------------------------------------: | :------: | :--------------------------------------------------------------------- | |
| 114 | +| `autoPlay` | `boolean` | `true` | `false` | Plays automatically while visible when reduced motion is not requested | |
| 115 | +| `children` | `React.ReactNode` | | `false` | Accepts native `<source>` elements | |
| 116 | +| `internalAccessibleLabels` | `{play: string, pause: string}` | `{play: 'Play video', pause: 'Pause video'}` | `false` | Sets accessible labels for the play and pause control | |
| 117 | +| `loop` | `boolean` | `true` | `false` | Repeats the video after playback ends | |
| 118 | +| `poster` | `string` | | `false` | Sets the image shown before playback begins | |
| 119 | +| `src` | `string` | | `false` | Sets the native video source URL | |
| 120 | +| `title` | `string` | | `true` | Provides an accessible name for the video | |
0 commit comments