Browse Source

优化连接录音笔

newdev_shunjiawei
tanlongsheng 1 year ago
parent
commit
c717928705
  1. 15
      lib/data/services/meeting/meeting_upload_service.dart
  2. 18
      lib/modules/meeting/controllers/meeting_connect_controller.dart
  3. 13
      lib/modules/meeting/controllers/meeting_home_controller.dart

15
lib/data/services/meeting/meeting_upload_service.dart

@ -26,10 +26,15 @@ class MeetingUploadService extends GetxService {
void _getUploadList() {
uploadList.value = _storage.read("meeting_upload_list") ?? [];
_executeUpload();
executeUpload();
}
void addUpload(int id, String filePath, String rootDir) async {
void addUpload(
int id,
String filePath,
String rootDir, {
bool isUpload = true,
}) async {
uploadList.add({
'id': id,
'filepath': filePath,
@ -38,10 +43,12 @@ class MeetingUploadService extends GetxService {
'isTask': false,
});
_storage.write("meeting_upload_list", uploadList);
_executeUpload();
if (isUpload) {
executeUpload();
}
}
void _executeUpload() async {
void executeUpload() async {
if (_isUpload) return;
_isUpload = true;
_handled = 0;

18
lib/modules/meeting/controllers/meeting_connect_controller.dart

@ -7,6 +7,7 @@ import 'package:path_provider/path_provider.dart';
import 'package:wifi_iot/wifi_iot.dart';
import '../../../core/utils/ftpconnect/ftpconnect.dart';
import '../../../data/services/meeting/meeting_upload_service.dart';
import 'meeting_home_controller.dart';
class MeetingConnectController extends GetxController {
@ -69,7 +70,6 @@ class MeetingConnectController extends GetxController {
_scanResultsSubscription.cancel();
_isScanningSubscription.cancel();
_valueReceivedSubscription?.cancel();
_ftpConnect?.disconnect();
_stopScan();
_disconnect();
super.onClose();
@ -100,6 +100,7 @@ class MeetingConnectController extends GetxController {
}
Future<void> _disconnect() async {
_ftpConnect?.disconnect();
await WiFiForIoTPlugin.forceWifiUsage(false);
await WiFiForIoTPlugin.disconnect();
await _device?.disconnect();
@ -233,10 +234,11 @@ class MeetingConnectController extends GetxController {
await _downloadFile(totalSize, previousSize, element);
await _ftpConnect?.deleteFile(element.name);
}
await _disconnect();
stateStr.value = '下载完成';
importedFilesStr.value = '下载完成,共${listDirectory.length}个文件,2秒后自动返回';
_disconnect();
Future.delayed(const Duration(seconds: 2), () {
_executeUpload();
Get.back();
});
}
@ -262,7 +264,17 @@ class MeetingConnectController extends GetxController {
fileSize.value = size;
},
);
await _meetingController.insertMeetingAudio(entry.name, filePath);
await _meetingController.insertMeetingAudio(
entry.name,
filePath,
isUpload: false,
);
}
Future<void> _executeUpload() async {
await Future.delayed(const Duration(seconds: 3));
final meetingUploadService = Get.find<MeetingUploadService>();
meetingUploadService.executeUpload();
}
String _decodePassword(List<int> data) {

13
lib/modules/meeting/controllers/meeting_home_controller.dart

@ -327,7 +327,11 @@ class MeetingHomeController extends GetxController {
EasyLoading.dismiss();
}
Future insertMeetingAudio(String fileName, String filePath) async {
Future insertMeetingAudio(
String fileName,
String filePath, {
bool isUpload = true,
}) async {
await _audioPlayer.setAudioSource(AudioSource.file(filePath));
int seconds = _audioPlayer.duration?.inSeconds ?? 0;
int creationTime = DateTime.now().millisecondsSinceEpoch;
@ -342,7 +346,12 @@ class MeetingHomeController extends GetxController {
};
final meetingId = await SqfliteApi.insertMeeting(data);
if (meetingId != null) {
meetingUploadService.addUpload(meetingId, filePath, 'ExternalAudio');
meetingUploadService.addUpload(
meetingId,
filePath,
'ExternalAudio',
isUpload: isUpload,
);
originalDataList.insert(0, {
'id': meetingId,
...data,

Loading…
Cancel
Save