stopRecording method

Future<void> stopRecording()

Stop recording the live stream

Implementation

Future<void> stopRecording() async {
  if (_room == null || !_isConnected) {
    throw StateError('Not connected to room. Call connectAndStart() first.');
  }

  try {
    // Request server-side recording stop
    final data = Uint8List.fromList(
      utf8.encode(jsonEncode({'action': 'stop_recording'})),
    );
    await _room!.localParticipant?.publishData(data, topic: 'recording');

    _isRecording = false;
    notifyListeners();
  } catch (e) {
    onPublishingError?.call(e);
    rethrow;
  }
}