Skip to navigation

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:

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

Define the player configuration

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

final configuration = FastPixPlayerConfiguration();

Initialize the controller

Connect your data source and configuration to the player:

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

Render the player widget

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

return FastPixPlayer(
controller: controller,
width: 350,
height: 200,
aspectRatio: FastPixAspectRatio.ratio16x9,
);

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

What’s next