loadAudioFile method
Implementation
Future<int?> loadAudioFile(String path) async {
const channel =
BasicMessageChannel<dynamic>('com.wangyng.better_sound_effect.loadAudioFile', StandardMessageCodec());
final Map<String, dynamic> requestMap = {"path": path};
final reply = await channel.send(requestMap);
if (!(reply is Map)) {
_throwChannelException();
}
Map<String, dynamic> replyMap = Map<String, dynamic>.from(reply);
if (replyMap['error'] != null) {
final HashMap<String, dynamic> error = replyMap['error'];
_throwException(error);
} else {
final result = replyMap["result"];
final soundId = result["soundId"];
return soundId is String ? int.parse(soundId) : soundId.toInt();
}
}