YPlayerController class
Controller for managing the YouTube player.
This class handles the initialization, playback control, and state management of the YouTube video player. It uses the youtube_explode_dart package to fetch video information and the media_kit package for playback.
Constructors
- YPlayerController.new({YPlayerStateCallback? onStateChanged, YPlayerProgressCallback? onProgressChanged})
- Constructs a YPlayerController with optional callback functions.
Properties
- currentQuality → int
-
Get the current selected quality
no setter
- duration → Duration
-
Gets the total duration of the video.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInitialized → bool
-
Checks if the player has been initialized with media.
no setter
- onProgressChanged → YPlayerProgressCallback?
-
Callback function triggered when the player's progress changes.
final
- onStateChanged → YPlayerStateCallback?
-
Callback function triggered when the player's status changes.
final
- player → Player
-
Gets the underlying media_kit Player instance.
no setter
- position → Duration
-
Enables background audio playback when screen is closed
Gets the current playback position.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → YPlayerStatus
-
Gets the current status of the player.
no setter
-
statusNotifier
→ ValueNotifier<
YPlayerStatus> -
Add this ValueNotifier to track status changes
final
Methods
-
chooseBestQualityForInternet(
StreamManifest manifest) → Future< int> - Select the best quality for the estimated network speed.
-
dispose(
) → void - Disposes of all resources used by the controller.
-
getAvailableQualities(
) → List< QualityOption> - Get list of available quality options
-
initialize(
String youtubeUrl, {bool autoPlay = true, double? aspectRatio, bool allowFullScreen = true, bool allowMuting = true, bool chooseBestQuality = true}) → Future< void> - Initializes the player with the given YouTube URL and settings.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
) → Future< void> - Pauses video playback.
-
play(
) → Future< void> - Starts or resumes video playback.
-
setQuality(
int height) → Future< void> - Change video quality
-
speed(
double speed) → Future< void> -
stop(
) → Future< void> - Stops video playback and resets to the beginning.
-
toString(
) → String -
A string representation of this object.
inherited
-
withHighestBitrate(
StreamManifest manifest) → dynamic
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited