AVPlayerController class

Controls a video player instance.

Communicates with the native platform through AvPlayerPlatform to play video, manage PIP mode, and handle media session controls.

Exposes player state via ValueNotifier so widgets can rebuild reactively with ValueListenableBuilder.

final controller = AVPlayerController(
  const AVVideoSource.network('https://example.com/video.mp4'),
);
await controller.initialize();
await controller.play();
Inheritance

Constructors

AVPlayerController(AVVideoSource source, {void onMediaCommand(AVMediaCommand command, {Duration? seekPosition})?})

Properties

hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isInitialized bool
Whether the controller has been initialized.
no setter
onMediaCommand → void Function(AVMediaCommand command, {Duration? seekPosition})?
Called when a media command is received from the notification or lock screen. Use this to handle next/previous track, or custom seek behavior.
final
playerId int?
The player ID (same as textureId). Null until initialized.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
source AVVideoSource
final
textureId int?
The texture ID used to render the video frame. Null until initialize completes successfully.
no setter
value AVPlayerState
The current value stored in this notifier.
getter/setter pairinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
enterPip({double? aspectRatio}) Future<void>
Enters Picture-in-Picture mode.
exitPip() Future<void>
Exits Picture-in-Picture mode.
getScreenBrightness() Future<double>
Returns the current screen brightness (0.0 to 1.0).
getSystemVolume() Future<double>
Returns the current system volume (0.0 to 1.0).
initialize() Future<void>
Initializes the player with the video source.
isPipAvailable() Future<bool>
Checks if PIP mode is available on this device.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
pause() Future<void>
Pauses playback.
play() Future<void>
Starts or resumes playback.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
seekTo(Duration position) Future<void>
Seeks to the given position.
setLooping(bool looping) Future<void>
Sets whether the video should loop.
setMediaMetadata(AVMediaMetadata metadata) Future<void>
Sets metadata for the media notification / lock screen display.
setNotificationEnabled(bool enabled) Future<void>
Enables or disables the media notification.
setPlaybackSpeed(double speed) Future<void>
Sets the playback speed. 1.0 is normal speed.
setScreenBrightness(double brightness) Future<void>
Sets the screen brightness. Range: 0.0 to 1.0.
setSystemVolume(double volume) Future<void>
Sets the system volume. Range: 0.0 to 1.0.
setVolume(double volume) Future<void>
Sets the player's volume. Range: 0.0 (mute) to 1.0 (max).
setWakelock(bool enabled) Future<void>
Enables or disables wakelock (prevents screen from turning off).
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited