Switch videos dynamically

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:

1final newDataSource = FastPixPlayerDataSource.hls(
2 playbackId: 'new-playback-id',
3 customDomain: 'new-domain.com',
4 token: 'new-token',
5);
6await 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.