editAudios method

Future<bool> editAudios(
  1. List<String> data,
  2. List<Map<TagType, dynamic>> tags
)

Used to edit multiples songs info.

Parameters:

  • data is used for find multiples audios data.
  • tags is used to define what tags and values you want edit.

Usage:

  // Tags
  List Map TagsType, dynamic>> tags = [];
  Map<TagsType, dynamic> getTags = {
    TagsType.TITLE: "New Title",
    TagsType.ARTIST: "New Artist"
  };
  tags.add(getTags);

  // Songs data
  List String> data;
  data.add(song1);
  data.add(song2);
  data.add(song3);
  bool result = await OnAudioEdit().editAudios(data, tags);
  print(result); //True or False

Important:

  • Calling any method without READ and WRITE permission will throw a error. Use permissionsStatus to see permissions status.
  • This method return true if audio has edited or false if don't.

Super Important:

  • This method works normal in Android below 10, from Android 10 or above user will need to accept access in Folder. You can see this "Complex Permission" status using complexPermissionStatus. By default when calling this method will open a new screen to user choose a folder, but you can anticipate the request using requestComplexPermission. The request status and folder permission will be saved as persistent but if user uninstall the app, this permission will be removed.

Implementation

Future<bool> editAudios(
  List<String> data,
  List<Map<TagType, dynamic>> tags,
) async {
  List<Map<int, dynamic>> finalList = [];
  for (var it1 in tags) {
    Map<int, dynamic> finalTags = {};
    it1.forEach((key, value) {
      _cannotModifiy(key);
      finalTags[key.index] = value;
    });
    finalList.add(finalTags);
  }
  final bool resultEditAudios = await _channel.invokeMethod("editAudios", {
    "data": data,
    "tags": finalList,
  });
  return resultEditAudios;
}