editAudio method

Future<bool> editAudio(
  1. String data,
  2. Map<TagType, dynamic> tags, {
  3. bool? searchInsideFolders,
})

Used to edit song info.

Parameters:

  • data is used for find specific audio data.
  • tags is used to define what tags and values you want edit.
  • searchInsideFolders is used for find specific audio data inside the folders. (Only required when using Android 10 or above)

Usage:

  Map<TagsType, dynamic> tags = {
    TagsType.TITLE: "New Title",
    TagsType.ARTIST: "New Artist"
  };
  bool song = await OnAudioEdit().editAudio(data, tags);
  print(song); //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.

Warning:

  • 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> editAudio(
  String data,
  Map<TagType, dynamic> tags, {
  bool? searchInsideFolders,
}) async {
  Map<int, dynamic> finalTags = {};
  tags.forEach((key, value) {
    _cannotModifiy(key);
    finalTags[key.index] = value;
  });
  final bool resultEditAudio = await _channel.invokeMethod("editAudio", {
    "data": data,
    "tags": finalTags,
    "searchInsideFolders": searchInsideFolders ?? false,
  });
  return resultEditAudio;
}