|
|
@@ -188,13 +188,13 @@ class RecordController extends BaseController {
|
|
|
Stream<Uint8List> recordStream = await _record.startStream(_recordConfig);
|
|
|
_setWakeLock();
|
|
|
_startForegroundService();
|
|
|
+ if (currentStatus.value != RecordStatus.recording) {
|
|
|
+ _changeRecordStatus(RecordStatus.recording);
|
|
|
+ }
|
|
|
recordStream.listen((data) async {
|
|
|
if (data.isEmpty) {
|
|
|
return;
|
|
|
}
|
|
|
- if (currentStatus.value != RecordStatus.recording) {
|
|
|
- _changeRecordStatus(RecordStatus.recording);
|
|
|
- }
|
|
|
targetFile.writeAsBytesSync(data, mode: FileMode.append);
|
|
|
currentDuration.value = currentDuration.value +
|
|
|
_getPcmDuration(data.length, _recordConfig.sampleRate, 16,
|
|
|
@@ -270,11 +270,13 @@ class RecordController extends BaseController {
|
|
|
}
|
|
|
}).catchError((error) {
|
|
|
if (error is ServerErrorException) {
|
|
|
- ToastUtil.showToast("${error.message}");
|
|
|
if (error.code == ErrorCode.errorCodeNoLogin) {
|
|
|
+ ToastUtil.showToast("录音已保存,请登录");
|
|
|
Get.toNamed(RoutePath.login)?.then((loginSuccess) {
|
|
|
loginSuccess != null && loginSuccess ? _saveCurrentRecord() : null;
|
|
|
});
|
|
|
+ } else {
|
|
|
+ ToastUtil.showToast("${error.message}");
|
|
|
}
|
|
|
} else {
|
|
|
ToastUtil.showToast("保存失败, 请重试");
|