Play uploaded videos

Learn how to play a FastPix video in your Flutter app using a playback ID.

Set up playback

Playing a video requires four steps: create a data source, define the player configuration, initialize the controller, and render the player widget.

Create a data source

The data source tells the player what to play. Provide your playbackId and optional metadata:

1final dataSource = FastPixPlayerDataSource.hls(
2 playbackId: 'your-playback-id-here',
3 title: 'Sample HLS Stream',
4 description: 'A sample HLS stream from FastPix',
5 thumbnailUrl: 'https://www.example.com/thumbnail.jpg',
6);

Define the player configuration

The configuration controls player behavior such as autoplay settings, quality preferences, and controls:

1final configuration = FastPixPlayerConfiguration();

Initialize the controller

Connect your data source and configuration to the player:

1controller = FastPixPlayerController();
2controller.initialize(dataSource: dataSource, configuration: configuration);

Render the player widget

Use the FastPixPlayer widget in your layout. You can control width, height, and aspect ratio:

1return FastPixPlayer(
2 controller: controller,
3 width: 350,
4 height: 200,
5 aspectRatio: FastPixAspectRatio.ratio16x9,
6);

Important: Always call controller.dispose() in your widget’s dispose() method. Forgetting this can cause memory leaks, especially on Android.

What’s next