Migrating to Better Player 1.x.x
Better Player 1.x.x introduces a federated plugin architecture and a significantly cleaner public API.
The package was split into smaller specialized packages, and redundant BetterPlayer prefixes were removed from model names.
1. Automated Migration (Recommended)
The easiest way to migrate your codebase is to use the automated Dart fix tool. We have provided a fix_data.yaml that will handle all the class renames for you.
Just run this in your terminal:
dart fix --apply
2. Real-world API Name Changes
To make the API cleaner and more idiomatic, almost all configuration and data models have dropped the BetterPlayer prefix. Here are side-by-side real-world examples of how to migrate your code in various scenarios.
Player & Data Source Configuration
| Before (0.8.x) | After (1.x.x) |
|---|---|
| |
Controls & UI Customization
| Before (0.8.x) | After (1.x.x) |
|---|---|
| |
Subtitles & Tracks
| Before (0.8.x) | After (1.x.x) |
|---|---|
| |
Playlists
| Before (0.8.x) | After (1.x.x) |
|---|---|
| |
Events & Utils
| Before (0.8.x) | After (1.x.x) |
|---|---|
| |
3. Parameter Renames
isPictureInPictureEnabledinBetterPlayerControllerhas been renamed toisPictureInPictureSupportedto better reflect its function (it checks if the hardware/OS supports PiP, not if it's currently turned on).
4. Migrating to v1.2.0 (Direct Native Bridges)
Better Player 1.2.0 replaces the legacy asynchronous MethodChannel communication with Direct Native Bridges.
This architectural shift provides higher performance, better type safety, and more reliable state synchronization.
What Changed?
- Android: Migrated to JNI using
jnigen. The plugin now communicates directly with the Java/Kotlin media engine without the overhead of MethodChannel serialization. - iOS: Migrated to Swift FFI using
swiftgen. This allows Dart to call intoAVPlayerlogic directly through the Objective-C runtime. - Platform Interface:
- Renamed
VideoPlayerPlatformtoBetterPlayerPlatform. - Removed
MethodChannelVideoPlayer.
- Renamed
Breaking Changes for Custom Implementations
If you have extended Better Player or implemented a custom platform backend, you must update your references:
-
Replace
VideoPlayerPlatformwithBetterPlayerPlatform:// Beforeclass MyCustomPlatform extends VideoPlayerPlatform { ... }// Afterclass MyCustomPlatform extends BetterPlayerPlatform { ... } -
Legacy
MethodChannelVideoPlayerRemoval: The classMethodChannelVideoPlayeris no longer available. All logic has been moved to the respective FFI/JNI implementations inbetter_player_androidandbetter_player_ios.