Secure video playback

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

1final dataSource = FastPixPlayerDataSource.hls(
2 playbackId: 'your-playback-id-here',
3 streamType: StreamType.onDemand,
4 token: "jwt-token",
5);

Secure live stream playback

1final dataSource = FastPixPlayerDataSource.hls(
2 playbackId: 'your-playback-id-here',
3 streamType: StreamType.live,
4 token: "jwt-token",
5);

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:

1final refreshedDataSource = FastPixPlayerDataSource.hls(
2 playbackId: 'your-playback-id-here',
3 streamType: StreamType.onDemand,
4 token: "new-jwt-token",
5);
6await controller.updateDataSource(refreshedDataSource);

For details on generating JWT tokens, see Secure playback with JWTs.