startRecorder method

Future<String> startRecorder (
  1. {String path,
  2. double maxVolume}
)

Start recorder

Implementation

Future<String> startRecorder({String path, double maxVolume}) async {
  assert(path != null);
  if (!isRecording) {
    isRecording = true;

    final params = {'path': path};

    if (maxVolume is double) {
      params.putIfAbsent('maxVolume', () => maxVolume.toString());
    }

    try {
      // if (_timer != null) {
      //   _timer.cancel();
      //   _timer = null;
      // }
      // _timer = _getCurrentTimeTimer(DateTime.now().millisecondsSinceEpoch,
      //     (int currentTime) {
      //   _recordListener(DateTime.now().millisecondsSinceEpoch - currentTime);
      // });
      String result = await _channel.invokeMethod('startRecorder', params);
      return result;
    } catch (e) {
      print(e);
    }
  }
  return 'Recorder is already recording.';
}