Monitor Better Player (Flutter)
Monitor Better Player (Flutter)
The FastPix Better Player Wrapper is a Flutter plugin that combines the power of BetterPlayer Plus with FastPix Video Data. It allows you to track granular playback metrics, measure viewer engagement, and monitor performance - all while preserving the native flexibility of BetterPlayer.
If you’re building a mobile video experience in Flutter and want accurate playback data without writing manual instrumentation, this wrapper takes care of that in a clean, extensible way.
Installation & Setup
Step 1: Add the SDK Dependency
You can install the FastPix Better Player Wrapper in one of two ways:
Option A: Using the terminal
Option B: Add the dependency directly
Alternatively, you can add the dependency directly in your pubspec.yaml:
Then run:
PLEASE NOTE
If you’re behind a proxy, or using a CI/CD runner, confirm that the SDK is being correctly fetched and cached. You can always verify installation by running
flutter pub deps.
Step 2: Platform configuration
FastPix Better Player Wrapper doesn’t require any additional configuration for iOS or Android.
- Android: Auto-configured by the plugin
- iOS: Auto-configured by the plugin
- No need to edit native files or add permissions manually - you’re good to go right after installation.
Basic usage
Step 1: Import the SDK
Now that the SDK is installed, you need to import it into any Dart file where you want to use FastPix player components. Typically, this will be in a page or file where you’ll implement video playback features - like your main.dart or any feature module.
At the very top of the file, add the import statement:
This import statement ensures that all the classes, methods, and functionalities provided by the FastPix Better Player Wrapper SDK are available for use in your project.
Step 2: Initialize BetterPlayer
Once the SDK is imported, you can begin working with its APIs. This includes initializing the player, configuring playback options, and handling video streams.
Step 3: Build the UI
Use the standard BetterPlayer widget to render the video.
Step 4: Clean up resources
To avoid memory leaks and dangling analytics sessions, dispose of the FastPix wrapper when the player is no longer in use.
Advanced configuration
The FastPix Better Player Wrapper supports custom metadata so you can enrich your video data with detailed context about videos, players, and user sessions.
Adding custom metadata
You can send custom tags, player details, and video attributes directly into FastPix analytics.
Event tracking & analytics
The SDK automatically tracks standard playback events without additional code.
Builder methods
FastPixBaseVideoPlayerBuilder : Used to configure and create a FastPix-wrapped player instance.
Configuration methods for customizing player behavior, metadata, and output:
Player instance methods
FastPixBaseBetterPlayer once built, the player provides lifecycle utilities:
Properties:
PlayerObserver implementation
The class implements PlayerObserver interface with these methods:
Error reporting
The SDK automatically captures and reports error details through ErrorModel:
Best practices
1. Resource management
Handles resource cleanup by disposing the FastPix wrapper before the controller.
2. Error handling
Wraps player initialization in a try–catch block to handle setup errors gracefully.
3. Configuration validation
Ensures required IDs and video URLs are valid before building the player.
4. Performance optimization
Applies settings to optimize performance and analytics, such as conditional logging and meaningful identifiers.
Complete integration example
Below is a complete example showing how to integrate FastPix Better Player Wrapper in a Flutter application:
This integration example demonstrates:
- Complete player initialization with error handling
- Proper resource cleanup
- UI state management
- Integration with state management solutions
- Best practices for production use