MediaControl class
A button to appear in the Android notification, lock screen, Android smart watch, or Android Auto device. The set of buttons you would like to display at any given moment should be streamed via AudioHandler.playbackState.
Each MediaControl button controls a specified MediaAction. Only the following actions can be represented as buttons:
- MediaAction.stop
- MediaAction.pause
- MediaAction.play
- MediaAction.rewind
- MediaAction.skipToPrevious
- MediaAction.skipToNext
- MediaAction.fastForward
- MediaAction.playPause
Predefined controls with default Android icons and labels are defined as
static fields of this class. If you wish to define your own custom Android
controls with your own icon resources, you will need to place the Android
resources in android/app/src/main/res
. Here, you will find a subdirectory
for each different resolution:
drawable-hdpi
drawable-mdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
You can use Android Asset Studio to generate these different subdirectories for any standard material design icon.
Constructors
- MediaControl.new({required String androidIcon, required String label, required MediaAction action, CustomMediaAction? customAction})
-
Creates a custom MediaControl.
const
-
MediaControl.custom({required String androidIcon, required String label, required String name, Map<
String, dynamic> ? extras}) - Creates a custom MediaControl.
Properties
- action → MediaAction
-
The action to be executed by this control
final
- androidIcon → String
-
A reference to an Android icon resource for the control (e.g.
"drawable/ic_action_pause"
)final - customAction → CustomMediaAction?
-
The custom action name and optional extras to receive in
AudioHandler.customAction
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- label → String
-
A label for the control
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copyWith(
{String? androidIcon, String? label, MediaAction? action, CustomMediaAction? customAction}) → MediaControl - Creates a copy of this control with given fields replaced by new values.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Constants
- fastForward → const MediaControl
- A default control for MediaAction.fastForward.
- pause → const MediaControl
- A default control for MediaAction.pause.
- play → const MediaControl
- A default control for MediaAction.play.
- rewind → const MediaControl
- A default control for MediaAction.rewind.
- skipToNext → const MediaControl
- A default control for MediaAction.skipToNext.
- skipToPrevious → const MediaControl
- A default control for MediaAction.skipToPrevious.
- stop → const MediaControl
- A default control for MediaAction.stop.