This SDK simplifies HLS video playback by offering a wide range of customization options for an enhanced viewing experience. It streamlines streaming setup by utilizing playback IDs that have reached the "ready" status to generate stream URLs. These playback IDs enable seamless integration and video playback within the FastPix-player, making the entire streaming process efficient and user-friendly.
-
- The
playbackId
allows for easy video playback by linking directly to the media file. Playback is available as soon as the media status is "ready." autoPlay
: Automatically starts playback once the video is loaded, providing a seamless user experience.loop
: Allows the video to repeat automatically after it finishes, perfect for continuous viewing scenarios.
- The
-
- the
token
attribute is required to play private or DRM protected streams - Note: You can skip the token for public streams.
- the
-
- The player includes inbuilt error handling that displays appropriate error messages, helping developers quickly understand and address any issues that arise during playback.
-
- The player automatically detects subtitles from the manifest file and displays them during playback. This ensures that users can easily access available subtitle tracks without additional configuration.
- Users can switch between available subtitles during playback, offering a personalized viewing experience. This feature allows viewers to choose their preferred language option easily.
-
- The player supports
onDemand
andlive
stream capabilities by utilizing specifiedstreamType
, enabling a versatile playback experience based on content type. - Manage video quality with
minResolution
,maxResolution
,resolution
andrenditionOrder
options, allowing either automated or controlled playback quality adjustments.
- The player supports
To get started with the FastPix Player SDK we need some prerequisites, follow these steps:
- Log in to the FastPix Dashboard: Navigate to the FastPix-Dashboard and log in with your credentials.
- Create Media: Start by creating a media using a pull or push method. You can also use our APIs instead for Push media or Pull media.
- Retrieve Media Details: After creation, access the media details by navigating to the "View Media" page.
- Get Playback ID: From the media details, obtain the playback ID.
- Play Video: Use the playback ID in the FastPix-player to play the video seamlessly.
To get started with the SDK, first install the FastPix Player SDK , you can use flutter pub add fastpix_player
command to directly add it:
Or
Add the dependency in your pubspec.yaml
:
dependencies:
fastpix_player: 0.1.0
import 'package:flutter/material.dart';
import 'package:fastpix_player/fastpix_video_player.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'FastPix Player Demo',
home: Scaffold(
appBar: AppBar(title: const Text('FastPix Player Example')),
body: const Center(
child: FastPixPlayerDemo(),
),
),
);
}
}
class FastPixPlayerDemo extends StatefulWidget {
const FastPixPlayerDemo({super.key});
@override
State<FastPixPlayerDemo> createState() => _FastPixPlayerDemoState();
}
class _FastPixPlayerDemoState extends State<FastPixPlayerDemo> {
late FastPixPlayerController controller;
@override
void initState() {
super.initState();
// Create HLS data source
final dataSource = FastPixPlayerDataSource.hls(
playbackId: 'your-playback-id-here',
title: 'Sample HLS Stream',
description: 'A sample HLS stream from staging.metrix.io',
thumbnailUrl: 'https://www.example.com/thumbnail.jpg',
);
final configuration = FastPixPlayerConfiguration();
// Initialize the controller
controller = FastPixPlayerController();
controller.initialize(dataSource: dataSource, configuration: configuration);
}
@override
Widget build(BuildContext context) {
return FastPixPlayer(
controller: controller,
width: 350,
height: 200,
aspectRatio: FastPixAspectRatio.ratio16x9,
);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
}
FastPix Player provides advanced quality control options:
// Quality control configuration
final qualityControl = FastPixPlayerQualityControl(
// Target specific resolution
resolution: FastPixResolution.p720,
// Or set min/max resolution range
minResolution: FastPixResolution.p480,
maxResolution: FastPixResolution.p1080,
// Rendition order (quality selection priority)
renditionOrder: FastPixRenditionOrder.desc, // High to low quality
);
// Apply quality control to data source
final dataSource = FastPixPlayerDataSource.hls(
playbackId: 'your-playback-id',
qualityControl: qualityControl,
);
FastPix Player provides multiple widget options:
FastPixPlayer( controller: controller,
width: 350,
height: 200,
aspectRatio: FastPixAspectRatio.ratio16x9,
showLoadingIndicator: true,
loadingIndicatorColor: Colors.white,
showErrorDetails: false,
)
The FastPixPlayerController
provides comprehensive control over the player:
// Playback control
await controller.play();
await controller.pause();
await controller.seekTo(Duration(seconds: 30));
await controller.setVolume(0.5);
// State information
final isPlaying = controller.isPlaying;
final isPaused = controller.isPaused;
final isFinished = controller.isFinished;
final currentState = controller.currentState;
// Position and duration
final currentPosition = controller.getCurrentPosition();
final totalDuration = controller.getTotalDuration();
// Data source management
await controller.updateDataSource(newDataSource);
await controller.updateConfiguration(newConfiguration);
await controller.updateDataSourceAndConfiguration(
dataSource: newDataSource,
configuration: newConfiguration,
);
final liveDataSource = FastPixPlayerDataSource.hls(
playbackId: 'live-stream-id',
streamType: StreamType.onDemand, // By Default StreamType is on-demand
cacheEnabled: false // Disable cache for streaming
);
final liveConfiguration = FastPixPlayerConfiguration(
autoPlayConfiguration: FastPixPlayerAutoPlayConfiguration(
autoPlay: FastPixAutoPlay.enabled,
),
controlsConfiguration: FastPixPlayerControlsConfiguration(),
);
For private media, token is required.
final liveDataSource = FastPixPlayerDataSource.hls(
playbackId: 'live-stream-id',
streamType: StreamType.onDemand, // By Default StreamType is on-demand
token: 'jwt-token' // Token is required for private media
);
final liveConfiguration = FastPixPlayerConfiguration(
autoPlayConfiguration: FastPixPlayerAutoPlayConfiguration(
autoPlay: FastPixAutoPlay.enabled,
),
controlsConfiguration: FastPixPlayerControlsConfiguration(),
);
final liveDataSource = FastPixPlayerDataSource.hls(
playbackId: 'live-stream-id',
streamType: StreamType.onDemand, // By Default StreamType is on-demand
customDomain: 'your custom domain goes here' // Ex: xyz.com
);
final liveConfiguration = FastPixPlayerConfiguration(
autoPlayConfiguration: FastPixPlayerAutoPlayConfiguration(
autoPlay: FastPixAutoPlay.enabled,
),
controlsConfiguration: FastPixPlayerControlsConfiguration(
showTimeRemaining: false, // Hide time remaining for live streams
),
);
For private media, token is required.
final liveDataSource = FastPixPlayerDataSource.hls(
playbackId: 'live-stream-id',
streamType: StreamType.onDemand, // By Default StreamType is on-demand
token: 'jwt-token', // Token is required for private media
customDomain: 'your custom domain goes here' // Ex: xyz.com
);
final liveConfiguration = FastPixPlayerConfiguration(
autoPlayConfiguration: FastPixPlayerAutoPlayConfiguration(
autoPlay: FastPixAutoPlay.enabled,
),
controlsConfiguration: FastPixPlayerControlsConfiguration(
showTimeRemaining: false, // Hide time remaining for live streams
),
);
The main controller class that manages the player state and configuration:
initialize(dataSource, configuration)
: Initialize the player with data source and configuration
dispose()
: Clean up resources
The main data source class that handles streaming configuration:
playbackId
(required): The unique identifier for your stream
title
: Optional title for the streamdescription
: Optional descriptioncustomDomain
: Custom streaming domain (defaults to staging.metrix.io)token
: Authentication token for protected streamsstreamType
: Set toStreamType.onDomand | StreamType.live
for live streamsheaders
: Optional HTTP headers for authenticationcacheEnabled
: Enable/disable video cachingloop
: Enable/disable video loopingqualityControl
: Quality control parametersshowSubtitles
: Whether to show subtitles by default
FastPixPlayerDataSource.hls()
: Create an HLS data source
Main configuration class for player behavior:
Advanced quality control parameters:
resolution
: Target resolution (auto, p360, p480, p720, p1080, p1440, p2160)minResolution
: Minimum allowed resolutionmaxResolution
: Maximum allowed resolution
renditionOrder
: Quality selection order (default_, asc, desc)
Basic player widget with minimal controls.
fit
: Fit to screenratio16x9
: 16:9 aspect ratioratio4x3
: 4:3 aspect ratioratio1x1
: 1:1 aspect ratio (square)stretch
: Stretch to fill
enabled
: Auto play enableddisabled
: Auto play disabledwifiOnly
: Auto play only on WiFi
auto
: Auto resolution selectionp360
: 360p resolutionp480
: 480p resolutionp720
: 720p resolutionp1080
: 1080p resolutionp1440
: 1440p resolutionp2160
: 2160p (4K) resolution
FastPix Player is designed specifically for streaming content from staging.metrix.io and other streaming services. It automatically constructs the correct streaming URLs based on your playback ID, custom domain, and chosen format, ensuring optimal performance and compatibility.
The controller-based API ensures predictable behavior by centralizing all data source and configuration management through the controller, eliminating the random behavior that could occur with duplicate parameter passing.
- Streaming-Only: Optimized for HLS streaming
- Quality Control: Advanced resolution and quality management
- Live Streaming: Optimized for live content
- Caching: Intelligent video caching
- Custom Domains: Support for custom streaming domains
- Authentication: Token-based authentication
- Error Handling: Comprehensive error management
For issues, feature requests, or contributions, please visit the project repository.