start method

  1. @override
Future<void> start({
  1. String? path,
  2. AudioEncoder encoder = AudioEncoder.AAC,
  3. int bitRate = 128000,
  4. double samplingRate = 44100.0,
})

Starts new recording session.

path: The output path file. If not provided will use temp folder. Ignored on web platform, output path is retrieve on stop.

encoder: The audio encoder to be used for recording. Ignored on web platform.

bitRate: The audio encoding bit rate in bits per second.

samplingRate: The sampling rate for audio in samples per second. Ignored on web platform.

Implementation

@override
Future<void> start({
  String? path,
  AudioEncoder encoder = AudioEncoder.AAC,
  int bitRate = 128000,
  double samplingRate = 44100.0,
}) async {
  _mediaRecorder?.stop();
  _resetMediaRecorder();

  try {
    final html.MediaStream? stream = await html.window.navigator.mediaDevices?.getUserMedia(<dynamic, dynamic>{
      'audio': true,
      'audioBitsPerSecond': bitRate,
      'bitsPerSecond': bitRate,
    });
    if (stream != null) {
      _onStart(stream);
    } else {
      if (kDebugMode) {
        print('Audio recording not supported.');
      }
    }
  } catch (error, stack) {
    _onError(error, stack);
  }
}