> From the [Strife developer docs](https://strife.app/docs/reference/field-reference/fields.video). Every page is listed in [llms.txt](https://strife.app/docs/llms.txt).

# fields.video()

Video field. Reads as the Video type: which Bunny Stream video was picked and how the editor wants it to play. videoSources() builds the HLS, MP4 and embed URLs.

Video field. Maps to editor `{ name: 'str-video', type: 'video' }`. Output is the canonical `Video` from `@strifeapp/types` (0.5.0 and later): which video from the team's video library was picked, and what the editor intends for it. How it plays is your site's choice.

## Example

```ts
fields.video({
  label: 'Promo video',
})
```

## Options

| Option         | Type      | Required | Description                                                |
| -------------- | --------- | -------- | ---------------------------------------------------------- |
| `label`        | `string`  | Yes      | Label shown to editors in Strife Studio.                   |
| `propertyName` | `string`  | No       | Override the stored property name.                         |

No `localizable` option, and no video-specific options beyond the common set.

## Output type

`Video`. Every key is optional: values saved by older versions of the editor carry only part of it, and an empty field is `{}`.

| Key | Type | Meaning |
| --- | --- | --- |
| `url` | `string \| null` | The best MP4 rendition the video has, such as `https://vz-example.b-cdn.net/<video id>/play_720p.mp4`. Older values may hold another file of the same video (`…/<video id>/original`). |
| `source` | `'1' \| '2'` | `'1'`: picked from Media. `'2'`: a pasted URL, written only by older versions. |
| `zone` | `string` | The video library's CDN origin, such as `https://vz-example.b-cdn.net`. |
| `guid` | `string` | The video's id in the library. |
| `library` | `number` | The video library's id. Only Bunny's embed player needs it. |
| `startTime` | `number \| string` | Where playback starts, in seconds. Older values store it as a string (`"12.3"`), so read it with `Number()`. |
| `playing` | `boolean` | Autoplay. Browsers only autoplay muted video, so mute it too. |
| `loop` | `boolean` | Start over at the end. |
| `muted` | `boolean` | Start without sound. |
| `controls` | `boolean` | Show the player controls. Applies to your own `<video>`; Bunny's embed always shows them. |
| `thumbnail` | `string \| null` | The video's thumbnail when it was picked. Changing the thumbnail in Media later does not update it. |
| `description` | `string` | A text alternative describing what the video shows. |
| `width`, `height` | `number \| null` | Intrinsic size in pixels. Set them on `<video>` so the page doesn't shift while it loads. |
| `duration` | `number \| null` | Length in seconds. |

## Playing it: `videoSources()`

`@strifeapp/strife/video` (1.22.0 and later) builds the playback URLs from a value:

```ts
import { videoSources } from '@strifeapp/strife/video';

const { hls, mp4, embed, poster, start } = videoSources(page.promo);
```

| Result | What it is |
| --- | --- |
| `hls` | The adaptive stream (`playlist.m3u8`). Safari and Chromium browsers play it in `<video>`; Firefox needs a library such as hls.js. Start it at `start` by setting `currentTime` on `loadedmetadata`. |
| `mp4` | The stored file, normally an MP4 rendition. Plays everywhere; append `#t=<start>` to start later. `null` when the value has no URL, or only an HLS playlist. |
| `embed` | Bunny's player for an `<iframe>`, with the editor's autoplay, loop, mute and start time. `null` without a `library`. |
| `poster` | The thumbnail, or `null`. |
| `start` | The start time in seconds, `0` when unset. |

A value that isn't a library video yields only `mp4` (its plain URL). An empty one yields `null` for every URL.

```astro
---
import { videoSources } from '@strifeapp/strife/video';
const { promo } = Astro.props;
const { mp4, poster, start } = videoSources(promo);
---
{mp4 && (
  <video
    src={start > 0 ? `${mp4}#t=${start}` : mp4}
    poster={poster ?? undefined}
    width={promo.width ?? undefined}
    height={promo.height ?? undefined}
    autoplay={promo.playing}
    muted={promo.muted || promo.playing}
    loop={promo.loop}
    controls={promo.controls}
    playsinline
    aria-label={promo.description || undefined}
  />
)}
```

## See also

* [Video](https://strife.app/docs/reference/fields/video.md): the same editor, documented from the Strife Studio UI side.
