startRecord method
void
startRecord()
Implementation
void startRecord() async {
try {
_myRecorder.stopRecorder();
} catch (e) {
//ignore
}
currentDuration.value = Duration.zero;
try {
bool hasStorage = await Permission.storage.isGranted;
bool hasMic = await Permission.microphone.isGranted;
if (!hasStorage || !hasMic) {
if (!hasStorage) await Permission.storage.request();
if (!hasMic) await Permission.microphone.request();
log('[chat_composer] 🔴 Denied permissions');
return;
}
if (onRecordStart != null) onRecordStart!();
Directory dir = await getApplicationDocumentsDirectory();
String path = '${dir.path}/${DateTime.now().millisecondsSinceEpoch}.aac';
await _myRecorder.startRecorder(
toFile: path,
codec: Codec.aacADTS,
);
emit(RecordAudioStarted());
} catch (e) {
emit(RecordAudioReady());
}
}