FlutterMediaSession class

The main entry point for the Flutter Media Session plugin.

This class provides a singleton interface to interact with the system media session. The recommended modern workflow is to bind an player adapter using bind.

Constructors

FlutterMediaSession()
Factory constructor to return the singleton instance.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

activate() → Future<void>
Activates the media session on the current platform.
bind(MediaSessionAdapter adapter) → void
Binds a MediaSessionAdapter to this media session instance.
clearActionHandler() → void
Clears the active action handler, if any.
deactivate() → Future<void>
Deactivates the media session and releases platform resources.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setActionHandler({VoidCallback? onPlay, VoidCallback? onPause, VoidCallback? onSkipToNext, VoidCallback? onSkipToPrevious, VoidCallback? onStop, void onSeekTo(Duration)?, VoidCallback? onRewind, VoidCallback? onFastForward, VoidCallback? onShuffle, VoidCallback? onRepeat, void onPlayFromMediaId(String mediaId, Duration? resumeFrom)?, void onPlayFromSearch(String query)?}) → void
Sets high-level callbacks to handle system media actions without manually listening to streams.
setActionLayout(ActionSlotLayout layout) → Future<void>
Sets the customizable action slot layout for system media controls.
setAppId(String id, {String? displayName, String? iconPath}) → Future<void>
Sets the application identity (App ID / AUMID / DesktopEntry) for the current process.
setAutoHandleInterruptions(bool enabled, {bool pauseWhenDucked = false}) → Future<void>
Opts the plugin into handling system audio interruptions (calls, navigation prompts, other apps grabbing audio).
setBackgroundKeepAlive(bool enabled) → Future<void>
Opts the session into a background keep-alive. Defaults to false.
setMediaLibrary({MediaLibraryChildrenProvider? getChildren}) → Future<void>
Opts into a browsable media library, shown by media browsers such as Android Auto.
setResumptionItem(MediaLibraryItem? item, {Duration position = Duration.zero}) → Future<void>
Saves what Android Auto, Bluetooth or the system's resume card should resume when they ask to play while nothing is loaded (Android Auto does on connect), kept while the app is closed. The resume arrives as MediaAction.playFromMediaId with MediaAction.isResumption and MediaAction.startPosition. With nothing saved (or after null), such a request is declined and nothing starts on its own.
setSkipIntervals({int forwardSeconds = 10, int backwardSeconds = 10}) → Future<void>
Sets the preferred skip intervals for rewind (backward) and fast-forward (forward) commands.
setWindowsAppUserModelId(String id, {String? displayName, String? iconPath}) → Future<void>
Sets the AppUserModelID for the current process on Windows.
toString() → String
A string representation of this object.
inherited
unbind() → void
Unbinds the currently active adapter, if any, and releases its resources.
wasStartedInBackground() → Future<bool>
Whether a media browser (Android Auto) started the app in the background while it was closed, through the shared engine (see the Android Auto section of the usage guide), rather than the user opening it.

Operators

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