> 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.

# Switch videos dynamically

> Learn how to change the video source at runtime without reinitializing the FastPix Flutter Player.

Learn how to change the video source at runtime without reinitializing the FastPix Flutter Player.

You can switch to a different video, refresh a JWT token, or change the custom domain without rebuilding the player. Use the `updateDataSource()` method on the controller.

## Update the data source

Create a new data source and pass it to the controller:

```dart
final newDataSource = FastPixPlayerDataSource.hls(
  playbackId: 'new-playback-id',
  customDomain: 'new-domain.com',
  token: 'new-token',
);
await controller.updateDataSource(newDataSource);
```

## When to use this

* Play a different video after the current one finishes.
* Refresh an expired JWT token without interrupting the player lifecycle.
* Switch between on-demand and live content within the same player instance.
* Change the custom domain for playback delivery.