> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# `<video>`

Plays a video from a network URL, like a `<video>`. It's experimental in Lynx 4.1. Attributes set up the player, and its methods start and stop playback: there's no `autoplay`.


## Usage

```typescript title="src/app/player.ts"
import { Component, ElementRef, viewChild } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';

@Component({
  selector: 'app-player',
  imports: [LYNX_ELEMENTS],
  template: `
    <video
      #player
      src="https://example.com/clip.mp4"
      object-fit="cover"
      style="width: 100%; height: 220px;"
    ></video>
    <view (bindtap)="play()"><text>Play</text></view>
  `,
})
export class Player {
  readonly player = viewChild.required('player', { read: ElementRef });

  // <video> has no autoplay: playback starts only through its play method.
  play(): void {
    this.player().nativeElement.invoke?.('play');
  }
}
```

Import `LYNX_ELEMENTS` in your component (see [Elements](/api/angular-lynx/elements/index.md)).

:::warning
Needs [XElement](/guide/glossary.md#xelement) in custom native apps (see [Embedding](/guide/embedding/index.md)).
:::

## Attributes

| Attribute             | Type                              | Default     | Description                                                                                                                                                                      |
| --------------------- | --------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `src`                 | `string`                          | —           | Video URL. Only network URLs work.                                                                                                                                               |
| `loop`                | `boolean`                         | `false`     | Starts again at the end.                                                                                                                                                         |
| `muted`               | `boolean`                         | `false`     | Mutes the sound.                                                                                                                                                                 |
| `volume`              | `number`                          | `1`         | iOS and Android. Volume, from `0` to `1`.                                                                                                                                        |
| `speed`               | `number`                          | `1`         | iOS and Android. Playback rate, from `0.1` to `2`.                                                                                                                               |
| `object-fit`          | `'contain' \| 'cover' \| 'fill'`  | `'contain'` | iOS and Android. How the video fills the element. It's an attribute here, not the CSS property.                                                                                  |
| `mode`                | `'queue' \| 'direct' \| 'latest'` | `'queue'`   | iOS and Android. How method calls run. `'queue'` waits for each call to finish before the next, `'direct'` runs each at once, and `'latest'` keeps only the newest waiting call. |
| `timeupdate-interval` | `number`                          | `0.33`      | iOS and Android. Minimum seconds between `bindtimeupdate` events.                                                                                                                |

Plus the [common attributes](/api/elements/view.md#attributes), such as `id`, `class` and `style`.

## Events

Read the payload from `$event.detail`. Angular types `$event` for each event: see [Element events](/api/angular-lynx/element-events.md#other-elements).

| Event            | `detail`                                  | Description                                                               |
| ---------------- | ----------------------------------------- | ------------------------------------------------------------------------- |
| `bindfirstframe` | `{ duration: number }`                    | The first frame loaded. `duration` is in seconds.                         |
| `bindplaying`    | —                                         | Playback started or resumed.                                              |
| `bindpaused`     | —                                         | Playback paused.                                                          |
| `bindstopped`    | —                                         | The `stop` method stopped playback.                                       |
| `bindtimeupdate` | `{ current: number; duration: number }`   | The playback position changed, in seconds.                                |
| `bindbuffering`  | `{ buffering: number }`                   | The video is buffering. `buffering` is how far it has loaded, in seconds. |
| `bindended`      | —                                         | Playback reached the end.                                                 |
| `bindlooped`     | —                                         | One loop finished, with `loop` on.                                        |
| `binderror`      | `{ errorCode: number; errorMsg: string }` | Playback failed.                                                          |

Plus the [common events](/api/elements/view.md#events), such as `bindtap`.

## Methods

These **UI methods** ([Glossary](/guide/glossary.md#ui-method)) control playback. Call them with `invoke()` on the element (see [Call element methods](/guide/selector-query.md)), as the [Usage](#usage) example does with `play`.

| Method  | Parameters             | Description                                   |
| ------- | ---------------------- | --------------------------------------------- |
| `play`  | —                      | Starts or resumes playback.                   |
| `pause` | —                      | Pauses playback.                              |
| `stop`  | —                      | iOS and Android. Stops playback.              |
| `seek`  | `{ position: number }` | iOS and Android. Jumps to `position` seconds. |

## Platform support

| Platform | Support                                                                                                                                   |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| iOS      | Lynx 4.1 and later.                                                                                                                       |
| Android  | Lynx 4.1 and later.                                                                                                                       |
| Web      | Partial: Lynx lists `src`, `loop`, `muted`, `play`, `pause`, and the `bindplaying`, `bindtimeupdate`, `bindended` and `binderror` events. |

## Related

- [Draw a video frame](/guide/canvas/media.md#draw-a-video-frame): draw a video's frame on a `<canvas>`, or play it on a three.js mesh
- [Call element methods](/guide/selector-query.md)
- [`<webview>`](/api/elements/webview.md): show web content, such as an embedded player
