BccmPlayerController class
The controller represents a player, and it's used to control and listen to player state.
You can use BccmPlayerController.primary to get the always-available primary player. See the docs for more info about the primary player.
As it is a ValueNotifier, you can also use it to listen to changes in the player state: BccmPlayerController.value.
Under the hood it's actually just a proxy to a StateNotifier
, which you can use directly via BccmPlayerController.stateNotifier.
This is useful if you want to use riverpod/flutter_state_notifier.
See also:
- primaryPlayerProvider and playerProviderFor for riverpod providers of the stateNotifier.
- BccmPlayerInterface.instance which is being used under the hood. You can use this to call methods directly on the native side given a playerId.
- BccmPlayerInterface.stateNotifier which holds some global state, including the primaryPlayerId and all active players.
- BccmPlayerController.primary which is the primary player.
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
PlayerState> - BccmPlayerController
Constructors
- BccmPlayerController(MediaItem mediaItem)
- Creates a BccmPlayerController with a MediaItem. Use with e.g. BccmPlayerView or VideoPlatformView.
- BccmPlayerController.empty()
- Creates a BccmPlayerController with an empty MediaItem.
- BccmPlayerController.networkUrl(Uri url, {String? mimeType})
- Convenience constructor to create a BccmPlayerController with a network url.
Properties
-
currentPlayerView
→ State<
VideoPlatformView> ? -
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isChromecast → bool
-
Checks if this player represents a cast session.
no setter
- isPrimary → bool
-
Checks if this player is the current primary player.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stateNotifier
→ StateNotifier<
PlayerState> ? -
no setter
- value ↔ PlayerState
-
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
-
attach(
State< VideoPlatformView> playerView) → void -
detach(
State< VideoPlatformView> playerView) → void -
dispose(
) → Future< void> -
Disposes the player.
The primary player can't be disposed.
override
-
enterNativeFullscreen(
) → Future - You are probably looking for BccmPlayerViewController.enterFullscreen.
-
exitNativeFullscreen(
) → Future - Exits native fullscreen. You might be looking for BccmPlayerViewController.exitFullscreen.
-
getTracks(
) → Future< PlayerTracksSnapshot?> - Gets the current video, audio and text tracks.
-
initialize(
) → Future< void> - Creates the player on the native side and starts loading the MediaItem which was implicitly or explicitly specificed in the constructor.
-
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 the video.
-
play(
) → Future< void> - Plays the current media item.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
replaceCurrentMediaItem(
MediaItem mediaItem, {bool? autoplay = true, bool? playbackPositionFromPrimary}) → Future< void> -
Replaces the current MediaItem with a new one.
If
autoplay
is true, the new MediaItem will start playing immediately. IfplaybackPositionFromPrimary
is true, the playback position will be copied from the primary player. -
seekTo(
Duration moment) → Future< void> - Seeks to a specific moment in the video. Example usage for skipping forward 20 seconds:
-
setMixWithOthers(
bool bool) → Future< void> - Sets to mix audio with other apps/players. Untested on iOS, where it might be a bit buggy because we are setting this setting multiple places.
-
setPlaybackSpeed(
double speed) → Future< void> - Sets the playback speed, where 1.0 is normal speed. The setting is kept across videos.
-
setPrimary(
) → void - Sets the player as the primary player. The primary player is the player that is used for casting and picture in picture.
-
setSelectedTrack(
TrackType type, String? trackId) → Future< void> - Sets the selected track. All other tracks of the same type will be unselected.
-
setVolume(
double volume) → Future< void> - Sets the volume. The value should be between 0.0 and 1.0. The setting is kept across videos.
-
stop(
{required bool reset}) → Future< void> - Stops the video.
-
swapPlayerNotifier(
PlayerStateNotifier notifier) → void - @internal as you probably don't need to use this. Used by the primaryController to swap between cast and local player.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- primary → BccmPlayerController
-
no setter