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
Changelog
All notable changes to the FastPix Better Player Wrapper project will be documented in this file.
[1.0.0] - 2026-05-22
Changed
- Dependency: Bumped
fastpix_flutter_core_datato^2.0.0. - PlayerObserver Interface: Refactored
FastPixBaseBetterPlayerto implement the updatedPlayerObserverinterface. - Custom Data API: Replaced
List<CustomData>with a singleCustomDataobject.setCustomDatanow accepts a singleCustomDatainstance instead of a list. - State Transitions: Updated state transition logic in
valid_events.dartto support more robust player states.
Added
- Position Poller: New position poller for finer-grained playback position tracking.
- 10s Pulse Timer: Periodic pulse timer for more reliable metric reporting during playback.
- Library Info: Added
LibraryInfoto track library metadata sent with analytics.
Fixed
- Android Plugin Registry: Updated
GeneratedPluginRegistrantto includeSqflitePlugin.
[0.1.0] - 2025-08-29
Added
- Core Plugin Structure: Complete Flutter plugin architecture with Android and iOS platform support
- BetterPlayer Integration: Seamless wrapper around BetterPlayer with full API compatibility
- FastPix Analytics Integration: Comprehensive video player metrics and tracking system
- Cross-Platform Support: Native implementation for both Android (Kotlin) and iOS platforms
- Event Tracking System: Automatic tracking of all major player events including:
- Player initialization and ready state
- Play, pause, and completion events
- Seeking and buffering operations
- Resolution and quality changes
- Error handling and reporting
- Builder Pattern Implementation: Clean and intuitive API using builder pattern for configuration
- Real-time Metrics Collection: Live tracking of player performance, user engagement, and playback quality
- Custom Data Support: Ability to attach custom metadata and analytics data to video sessions
- Player Dimension Tracking: Automatic detection and reporting of player size and resolution
- Audio Language Detection: Support for multiple audio tracks and language identification
- Comprehensive Error Handling: Robust error tracking with detailed error models and reporting
- Logging System: Optional detailed logging for debugging and development purposes
- Performance Optimization: Efficient event handling with debouncing for iOS seek operations
- Memory Management: Proper resource cleanup and disposal methods
- Flutter Core SDK Integration: Built-in integration with FastPix core analytics SDK
Technical Features
- Platform Interface: Implements
PlayerObserverinterface for analytics integration - Event Listener Management: Efficient event handling with BetterPlayer event system
- State Management: Comprehensive player state tracking and management
- Configuration Management: Flexible configuration system with required and optional parameters
- Type Safety: Full Dart type safety with null safety support
- Performance Monitoring: Real-time performance metrics and analytics data collection