play method

void play({
  1. required Sound sound,
  2. String? customSound,
  3. String? packageName,
})

Implementation

void play(
    {required Sound sound,
    String? customSound,
    String? packageName // Use it only when using other plugin
    }) async {
  String soundPath = "";

  if (customSound != null && customSound.isNotEmpty) {
    soundPath = customSound;

    if (Platform.isAndroid && packageName != null && packageName.isNotEmpty) {
      soundPath = "packages/$packageName/$soundPath";
    }
  } else {
    soundPath = _getDefaultSoundPath(sound);
    packageName ??= UIConstants.packageName;
    if (Platform.isAndroid) {
      //if (packageName != null && packageName.isNotEmpty) {
      soundPath = "packages/$packageName/$soundPath";
      // } else {
      //   _soundPath = "packages/${UIConstants.packageName}/" + _soundPath;
      // }
    }
  }

  await UIConstants.channel.invokeMethod("playCustomSound",
      {'assetAudioPath': soundPath, 'package': packageName});
}