setSupportedMediaActions method
Set the supported actions in the OS's background audio system.
Informs device displays and external controllers (e.g. watch/auto) on what controls to display.
Implementation
void setSupportedMediaActions(Set<MediaActionType> actions,
{double? skipIntervalSeconds}) async {
const Map<MediaActionType, String> mediaActionTypeToString =
<MediaActionType, String>{
MediaActionType.playPause: mediaPlayPause,
MediaActionType.pause: mediaPause,
MediaActionType.play: mediaPlay,
MediaActionType.next: mediaNext,
MediaActionType.previous: mediaPrevious,
MediaActionType.seekForward: mediaSeekForward,
MediaActionType.seekBackward: mediaSeekBackward,
MediaActionType.seekTo: mediaSeekTo,
MediaActionType.skipForward: mediaSkipForward,
MediaActionType.skipBackward: mediaSkipBackward,
};
final List<String> actionStrings = actions
.map((MediaActionType type) => mediaActionTypeToString[type]!).toList();
final Map<String, dynamic> map = <String, dynamic>{
mediaActionsKey: actionStrings
};
if (skipIntervalSeconds != null) {
map[mediaSkipIntervalSecondsKey] = skipIntervalSeconds;
}
await audioMethodChannel.invokeMethod<dynamic>(
setSupportedMediaActionsMethod, map);
}