playAll method

Future<Result> playAll(
  1. List<String> urls, {
  2. int index = 0,
  3. bool repeatMode = false,
  4. bool respectAudioFocus = false,
  5. Duration position = const Duration(milliseconds: 0),
  6. PlayerMode playerMode = PlayerMode.BACKGROUND,
  7. List<AudioNotification> audioNotifications = const [],
})

Plays your playlist.

If PlayerMode is set to PlayerMode.FOREGROUND, then you also need to pass: audioNotifications for providing the foreground notification.

Implementation

Future<Result> playAll(
  List<String> urls, {
  int index = 0,
  bool repeatMode = false,
  bool respectAudioFocus = false,
  Duration position = const Duration(milliseconds: 0),
  PlayerMode playerMode = PlayerMode.BACKGROUND,
  List<AudioNotification> audioNotifications = const [],
}) async {
  if (audioNotifications.length != urls.length &&
      playerMode == PlayerMode.FOREGROUND) return Result.ERROR;

  return ResultMap[await _invokeMethod('playAll', {
        'urls': urls,
        'repeatMode': repeatMode,
        'isBackground': playerMode == PlayerMode.BACKGROUND,
        'respectAudioFocus': respectAudioFocus,
        'position': position.inMilliseconds,
        'index': index,
        // audio notification objects
        'smallIconFileNames':
            audioNotifications.map((e) => e.smallIconFileName).toList(),
        'titles': audioNotifications.map((e) => e.title).toList(),
        'subTitles': audioNotifications.map((e) => e.subTitle).toList(),
        'largeIconUrls':
            audioNotifications.map((e) => e.largeIconUrl).toList(),
        'isLocals': audioNotifications.map((e) => e.isLocal).toList(),
        'notificationDefaultActionsList': audioNotifications
            .map((e) =>
                NotificationDefaultActionsMap[e.notificationDefaultActions])
            .toList(),
        'notificationActionCallbackModes': audioNotifications
            .map((e) => NotificationActionCallbackModeMap[
                e.notificationActionCallbackMode])
            .toList(),
        'notificationCustomActionsList': audioNotifications
            .map((e) =>
                NotificationCustomActionsMap[e.notificationCustomActions])
            .toList(),
      }) as int] ??
      Result.ERROR;
}