start static method
- @Deprecated("Use init instead.")
- 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),
Deprecated. The new AudioHandler API now automatically starts the service when your implementation enters the playing state. Parameters can be passed via AudioHandler.customAction.
Implementation
@Deprecated("Use init instead.")
static Future<bool> 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),
}) async {
if (!androidEnableQueue) {
// ignore: avoid_print
print('NOTE: androidEnableQueue is always true from 0.18.0 onwards.');
}
if (_cacheManager != null && _handler.playbackState.hasValue) {
if (_handler.playbackState.nvalue!.processingState !=
AudioProcessingState.idle) {
return false;
}
}
AudioServiceBackground._startCompleter = Completer<BackgroundAudioTask>();
backgroundTaskEntrypoint();
final task = await AudioServiceBackground._startCompleter!.future;
task._handler = _BackgroundAudioHandler();
task._handler._task = task;
AudioServiceBackground._startCompleter = null;
if (_cacheManager == null) {
_compatibilitySwitcher.inner = task._handler;
await init(
builder: () => _compatibilitySwitcher,
config: AudioServiceConfig(
androidResumeOnClick: androidResumeOnClick,
androidNotificationChannelName: androidNotificationChannelName,
androidNotificationChannelDescription:
androidNotificationChannelDescription,
notificationColor: androidNotificationColor != null
? Color(androidNotificationColor)
: null,
androidNotificationIcon: androidNotificationIcon,
androidShowNotificationBadge: androidShowNotificationBadge,
androidNotificationClickStartsActivity:
androidNotificationClickStartsActivity,
androidNotificationOngoing: androidNotificationOngoing,
androidStopForegroundOnPause: androidStopForegroundOnPause,
artDownscaleWidth: androidArtDownscaleSize?.width.round(),
artDownscaleHeight: androidArtDownscaleSize?.height.round(),
fastForwardInterval: fastForwardInterval,
rewindInterval: rewindInterval,
),
);
} else {
_compatibilitySwitcher.inner = task._handler;
}
await task.onStart(params);
return true;
}