---
title: "videoMedia"
description: "A video from a URL prop, playing in the layer."
group: "paint"
groupTitle: "Painting"
categoryId: "media"
categorySlug: "media"
categoryTitle: "Media"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/media.ts#L134"
---

# videoMedia

A video from a URL prop, playing in the layer.

```ts
videoMedia(opts: MediaFitSlots & {
    /** The URL prop. */
    src: PropRef
    /** The loop prop, synced to the video each frame. */
    loop: PropRef
    /** Milliseconds to wait for the video's metadata before giving up. */
    metadataTimeoutMs: number
    onError?: (
  error: unknown,
  info: {url: string | null; stage: 'acquire' | 'autoplay'},
) => void
}): MediaSurfaceHalf
```

Import `media` from `shaders/std` and use `media.videoMedia`.

The video plays muted and inline. `loop` is a boolean prop. `metadataTimeoutMs` is how long to wait for the video's metadata before reporting a failure. Set `naturalSizeKey: {fromProp: 'url'}` on the definition. `onError` tells you whether loading (`'acquire'`) or playback (`'autoplay'`) failed.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `opts` | `MediaFitSlots & {
    /** The URL prop. */
    src: PropRef
    /** The loop prop, synced to the video each frame. */
    loop: PropRef
    /** Milliseconds to wait for the video's metadata before giving up. */
    metadataTimeoutMs: number
    onError?: (error: unknown, info: {url: string \| null; stage: 'acquire' \| 'autoplay'}) => void
}` |  |

## Example

```ts
...videoMedia({src: p('url'), fit: p('objectFit'), loop: p('loop'), decode: 'srgb-linear-alpha-cut', metadataTimeoutMs: 10000})
```

## See also

- [`imageMedia`](/docs/primitives/media/imagemedia) — An image from a URL prop, fitted into the layer.
- [`webcamMedia`](/docs/primitives/media/webcammedia) — The user's camera, live in the layer.

## Used by

[VideoTexture](/docs/components/videotexture)