startStream method

Future<Stream<Uint8List>> startStream(
  1. RecordConfig config
)

Same as start with output stream instead of a path.

When stopping the record, you must rely on stream close event to get full recorded data.

Implementation

Future<Stream<Uint8List>> startStream(RecordConfig config) async {
  _created ??= await _create();
  await _stopRecordStream();

  final stream = await RecordPlatform.instance.startStream(
    _recorderId,
    config,
  );

  _recordStreamCtrl = StreamController.broadcast();

  _recordStreamSubscription = stream.listen(
    (data) {
      final streamCtrl = _recordStreamCtrl;
      if (streamCtrl == null || streamCtrl.isClosed) return;

      streamCtrl.add(data);
    },
  );

  _startAmplitudeTimer();

  return _recordStreamCtrl!.stream;
}