AudioService class
Provides an API to manage the app's AudioHandler. An app must call init during initialisation to register the AudioHandler that will service all requests to play audio.
Constructors
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
addQueueItem
→ Future<
void> Function(MediaItem mediaItem) -
Deprecated. Use AudioHandler.addQueueItem instead.
final
-
asyncError
→ Stream<
Object> -
A stream that broadcasts any exceptions that occur asynchronously.
no setter
-
browseMediaChildren
→ List<
MediaItem> ? -
Deprecated. Use AudioHandler.getChildren instead.
no setter
-
browseMediaChildrenStream
→ Stream<
List< MediaItem> > -
Deprecated. Directly subscribe to a parent's children via
AudioHandler.subscribeToChildren.
no setter
- cacheManager → BaseCacheManager
-
The cache to use when loading artwork.
Defaults to
DefaultCacheManager
.no setter -
click
→ Future<
void> Function([MediaButton]) -
Deprecated. Use AudioHandler.click instead.
final
- config → AudioServiceConfig
-
The current configuration.
no setter
- currentMediaItem → MediaItem?
-
Deprecated. Use
value
of AudioHandler.mediaItem instead.no setter -
currentMediaItemStream
→ ValueStream<
MediaItem?> -
Deprecated. Use AudioHandler.mediaItem instead.
no setter
-
customAction
→ Future Function(String, Map<
String, dynamic> ) -
Deprecated. Use AudioHandler.customAction instead.
final
- customEventStream → Stream
-
Deprecated. Use AudioHandler.customEvent instead.
no setter
-
fastForward
→ Future<
void> Function() -
Deprecated. Use AudioHandler.fastForward instead.
final
-
notificationClicked
→ ValueStream<
bool> -
A stream that broadcasts the status of the notificationClick event.
no setter
-
notificationClickEventStream
→ ValueStream<
bool> -
Deprecated. Use notificationClicked instead.
no setter
-
pause
→ Future<
void> Function() -
Deprecated. Use AudioHandler.pause instead.
final
-
play
→ Future<
void> Function() -
Deprecated. Use AudioHandler.play instead.
final
- playbackState → PlaybackState
-
Deprecated. Use
value
of AudioHandler.playbackState instead.no setter -
playbackStateStream
→ ValueStream<
PlaybackState> -
Deprecated. Use AudioHandler.playbackState instead.
no setter
-
playFromMediaId
→ Future<
void> Function(String, [Map<String, dynamic> ]) -
Deprecated. Use AudioHandler.playFromMediaId instead.
final
-
playMediaItem
→ Future<
void> Function(MediaItem mediaItem) -
Deprecated. Use AudioHandler.playMediaItem instead.
final
-
position
→ Stream<
Duration> -
A stream tracking the current position, suitable for animating a seek bar.
To ensure a smooth animation, this stream emits values more frequently on
short media items where the seek bar moves more quickly, and less
frequenly on long media items where the seek bar moves more slowly. The
interval between each update will be no quicker than once every 16ms and
no slower than once every 200ms.
final
-
positionStream
→ ValueStream<
Duration> -
Deprecated. Use position instead.
final
-
prepare
→ Future<
void> Function() -
Deprecated. Use AudioHandler.prepare instead.
final
-
prepareFromMediaId
→ Future<
void> Function(String, [Map<String, dynamic> ]) -
Deprecated. Use AudioHandler.prepareFromMediaId instead.
final
-
queue
→ List<
MediaItem> ? -
Deprecated. Use
value
of AudioHandler.queue instead.no setter -
queueStream
→ ValueStream<
List< MediaItem> ?> -
Deprecated. Use AudioHandler.queue instead.
no setter
-
removeQueueItem
→ Future<
void> Function(MediaItem mediaItem) -
Deprecated. Use AudioHandler.removeQueueItem instead.
final
-
rewind
→ Future<
void> Function() -
Deprecated. Use AudioHandler.rewind instead.
final
- running → bool
-
Deprecated. Use PlaybackState.processingState of AudioHandler.playbackState instead.
no setter
-
runningStream
→ ValueStream<
bool> -
Deprecated. Use AudioHandler.playbackState instead.
no setter
-
seekBackward
→ Future<
void> Function(bool begin) -
Deprecated. Use AudioHandler.seekBackward instead.
final
-
seekForward
→ Future<
void> Function(bool begin) -
Deprecated. Use AudioHandler.seekForward instead.
final
-
seekTo
→ Future<
void> Function(Duration position) -
Deprecated. Use AudioHandler.seek instead.
final
-
setRepeatMode
→ Future<
void> Function(AudioServiceRepeatMode repeatMode) -
Deprecated. Use AudioHandler.setRepeatMode instead.
final
-
setShuffleMode
→ Future<
void> Function(AudioServiceShuffleMode shuffleMode) -
Deprecated. Use AudioHandler.setShuffleMode instead.
final
-
setSpeed
→ Future<
void> Function(double speed) -
Deprecated. Use AudioHandler.setSpeed instead.
final
-
skipToNext
→ Future<
void> Function() -
Deprecated. Use AudioHandler.skipToNext instead.
final
-
skipToPrevious
→ Future<
void> Function() -
Deprecated. Use AudioHandler.skipToPrevious instead.
final
-
stop
→ Future<
void> Function() -
Deprecated. Use AudioHandler.stop instead.
final
-
updateMediaItem
→ Future<
void> Function(MediaItem mediaItem) -
Deprecated. Use AudioHandler.updateMediaItem instead.
final
-
updateQueue
→ Future<
void> Function(List<MediaItem> queue) -
Deprecated. Use AudioHandler.updateQueue instead.
final
Static Methods
-
addQueueItemAt(
MediaItem mediaItem, int index) → Future< void> - Deprecated. Use AudioHandler.insertQueueItem instead.
-
addQueueItems(
List< MediaItem> mediaItems) → Future<void> - Deprecated. Use AudioHandler.addQueueItems instead.
-
androidForceEnableMediaButtons(
) → Future< void> - In Android, forces media button events to be routed to your active media session.
-
createPositionStream(
{int steps = 800, Duration minPeriod = const Duration(milliseconds: 200), Duration maxPeriod = const Duration(milliseconds: 200)}) → Stream< Duration> -
Creates a new stream periodically tracking the current position. The
stream will aim to emit
steps
position updates at intervals of current MediaItem.duration /steps
. This interval will be clipped betweenminPeriod
andmaxPeriod
. This stream will not emit values while audio playback is paused or stalled. -
init<
T extends AudioHandler> ({required T builder(), AudioServiceConfig? config, BaseCacheManager? cacheManager}) → Future< T> - Register the app's AudioHandler with configuration options. This must be called once during the app's initialisation so that it is prepared to handle audio requests immediately after a cold restart (e.g. if the user clicks on the play button in the media notification while your app is not running and your app needs to be woken up).
-
setBrowseMediaParent(
[String parentMediaId = browsableRootId]) → Future< void> - Deprecated. Instead, subscribe directly to a parent's children via AudioHandler.subscribeToChildren.
-
setRating(
Rating rating, Map extras) → Future< void> - Deprecated. Use AudioHandler.setRating instead.
-
skipToQueueItem(
String mediaId) → Future< void> - Deprecated. Use AudioHandler.skipToQueueItem instead.
-
start(
{required Function backgroundTaskEntrypoint, Map< String, dynamic> ? params, String androidNotificationChannelName = "Notifications", String? androidNotificationChannelDescription, int? androidNotificationColor, String androidNotificationIcon = 'mipmap/ic_launcher', bool androidShowNotificationBadge = false, bool androidNotificationClickStartsActivity = true, bool androidNotificationOngoing = false, bool androidResumeOnClick = true, bool androidStopForegroundOnPause = false, bool androidEnableQueue = false, Size? androidArtDownscaleSize, Duration fastForwardInterval = const Duration(seconds: 10), Duration rewindInterval = const Duration(seconds: 10)}) → Future<bool> - Deprecated. The new AudioHandler API now automatically starts the service when your implementation enters the playing state. Parameters can be passed via AudioHandler.customAction.
Constants
- browsableRootId → const String
- The root media ID for browsing media provided by the background task.
- MEDIA_ROOT_ID → const String
- Deprecated. Use browsableRootId instead.
- recentRootId → const String
- The root media ID for browsing the most recently played item(s).