> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# Secure video playback

> Learn how to protect video content using JWT tokens in the FastPix Flutter Player.

Learn how to protect video content using JWT tokens in the FastPix Flutter Player.

The FastPix Flutter Player supports token-based authentication for both on-demand and live streams. Pass a valid JWT token in the data source to restrict access to authorized viewers.

## Secure on-demand playback

```dart
final dataSource = FastPixPlayerDataSource.hls(
  playbackId: 'your-playback-id-here',
  streamType: StreamType.onDemand,
  token: "jwt-token",
);
```

## Secure live stream playback

```dart
final dataSource = FastPixPlayerDataSource.hls(
  playbackId: 'your-playback-id-here',
  streamType: StreamType.live,
  token: "jwt-token",
);
```

## How tokens protect your content

* Only viewers with a valid, cryptographically signed token can access the stream.
* Tokens can include expiration timestamps, restricting playback to a defined time window.
* Tokens can be generated per user or session for user-specific access control.
* Signed tokens prevent unauthorized URL sharing, protecting content from piracy and hotlinking.

## Refresh tokens at runtime

If a token expires during a session, you can update the data source without reinitializing the player:

```dart
final refreshedDataSource = FastPixPlayerDataSource.hls(
  playbackId: 'your-playback-id-here',
  streamType: StreamType.onDemand,
  token: "new-jwt-token",
);
await controller.updateDataSource(refreshedDataSource);
```

For details on generating JWT tokens, see [Secure playback with JWTs](/docs/video-security/generate-jwts-for-secure-media).