|
|
|
@ -13,16 +13,18 @@ import 'package:permission_handler/permission_handler.dart'; |
|
|
|
|
|
|
|
import '../../../core/utils/logger.dart'; |
|
|
|
import '../../../core/utils/synchrodata.dart'; |
|
|
|
import '../../../core/utils/upload_oss.dart'; |
|
|
|
import '../../../data/services/ble_manager.dart'; |
|
|
|
import '../../../data/services/db/sqflite_api.dart'; |
|
|
|
import '../../../core/utils/permission_util.dart'; |
|
|
|
|
|
|
|
import 'package:share_plus/share_plus.dart'; |
|
|
|
|
|
|
|
import '../../../data/services/meeting/meeting_upload_service.dart'; |
|
|
|
import '../../../routes/app_routes.dart'; |
|
|
|
|
|
|
|
class MeetingController extends GetxController { |
|
|
|
final _meetingUploadService = Get.find<MeetingUploadService>(); |
|
|
|
|
|
|
|
final ScrollController listController = ScrollController(); |
|
|
|
final AudioPlayer _audioPlayer = AudioPlayer(); |
|
|
|
|
|
|
|
@ -224,10 +226,6 @@ class MeetingController extends GetxController { |
|
|
|
final fileStat = await file.stat(); |
|
|
|
final creationTime = fileStat.changed.millisecondsSinceEpoch; |
|
|
|
|
|
|
|
// 上传OSS |
|
|
|
final audiourl = |
|
|
|
await UploadOss.upload(filepath: filePath, rootDir: 'LocalAudio'); |
|
|
|
|
|
|
|
// 准备新路径 |
|
|
|
final fileName = filePath.split('/').last; |
|
|
|
final newPath = "${destDir.path}/$fileName"; |
|
|
|
@ -238,7 +236,7 @@ class MeetingController extends GetxController { |
|
|
|
'type': 'LOCAL', |
|
|
|
'seconds': seconds, |
|
|
|
'filepath': newPath, // 存储新路径 |
|
|
|
'audiourl': audiourl, |
|
|
|
'audiourl': '', |
|
|
|
'tasktype': 0, |
|
|
|
'creationtime': creationTime, |
|
|
|
}; |
|
|
|
@ -246,6 +244,9 @@ class MeetingController extends GetxController { |
|
|
|
// 插入数据库 |
|
|
|
final meetingId = await SqfliteApi.insertMeeting(data); |
|
|
|
if (meetingId != null) { |
|
|
|
// 上传OSS |
|
|
|
_meetingUploadService.addUpload(meetingId, newPath, 'LocalAudio'); |
|
|
|
|
|
|
|
// 更新UI数据 |
|
|
|
dataList.insert(0, { |
|
|
|
'id': meetingId, |
|
|
|
@ -279,8 +280,6 @@ class MeetingController extends GetxController { |
|
|
|
await _audioPlayer.setAudioSource(AudioSource.file(filePath)); |
|
|
|
final fileStat = await File(filePath).stat(); |
|
|
|
final creationTime = fileStat.changed.millisecondsSinceEpoch; // 时间戳 |
|
|
|
var audiourl = await UploadOss.upload( |
|
|
|
filepath: filePath, rootDir: 'TranslatAudio'); |
|
|
|
int seconds = _audioPlayer.duration?.inSeconds ?? 0; |
|
|
|
final fileName = filePath.split('/').last; |
|
|
|
Map<String, Object?> data = { |
|
|
|
@ -288,12 +287,14 @@ class MeetingController extends GetxController { |
|
|
|
'type': 'TRANSLAT', |
|
|
|
'seconds': seconds, |
|
|
|
'filepath': filePath, |
|
|
|
'audiourl': audiourl, |
|
|
|
'audiourl': '', |
|
|
|
'tasktype': 0, |
|
|
|
'creationtime': creationTime, |
|
|
|
}; |
|
|
|
final meetingId = await SqfliteApi.insertMeeting(data); |
|
|
|
if (meetingId != null) { |
|
|
|
_meetingUploadService.addUpload(meetingId, filePath, 'TranslatAudio'); |
|
|
|
|
|
|
|
dataList.insert(0, { |
|
|
|
'id': meetingId, |
|
|
|
'taskid': '', |
|
|
|
@ -330,9 +331,7 @@ class MeetingController extends GetxController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var audiourl = |
|
|
|
await UploadOss.upload(filepath: filePath, rootDir: 'ExternalAudio'); |
|
|
|
final meetingId = await insertMeetingAudio(fileName, filePath, audiourl); |
|
|
|
final meetingId = await insertMeetingAudio(fileName, filePath); |
|
|
|
|
|
|
|
if (isParamProvided) { |
|
|
|
Get.toNamed(Routes.meetingDetails, arguments: { |
|
|
|
@ -342,8 +341,7 @@ class MeetingController extends GetxController { |
|
|
|
EasyLoading.dismiss(); |
|
|
|
} |
|
|
|
|
|
|
|
Future insertMeetingAudio( |
|
|
|
String fileName, String filePath, String audiourl) async { |
|
|
|
Future insertMeetingAudio(String fileName, String filePath) async { |
|
|
|
await _audioPlayer.setAudioSource(AudioSource.file(filePath)); |
|
|
|
int seconds = _audioPlayer.duration?.inSeconds ?? 0; |
|
|
|
int creationTime = DateTime.now().millisecondsSinceEpoch; |
|
|
|
@ -352,12 +350,14 @@ class MeetingController extends GetxController { |
|
|
|
'type': 'IMPORT', |
|
|
|
'seconds': seconds, |
|
|
|
'filepath': filePath, |
|
|
|
'audiourl': audiourl, |
|
|
|
'audiourl': '', |
|
|
|
'tasktype': 0, |
|
|
|
'creationtime': creationTime, |
|
|
|
}; |
|
|
|
final meetingId = await SqfliteApi.insertMeeting(data); |
|
|
|
if (meetingId != null) { |
|
|
|
_meetingUploadService.addUpload(meetingId, filePath, 'ExternalAudio'); |
|
|
|
|
|
|
|
dataList.insert(0, { |
|
|
|
'id': meetingId, |
|
|
|
'taskid': '', |
|
|
|
|