|
|
@ -22,6 +22,7 @@ import '../../../data/services/meeting/meeting_task_service.dart'; |
|
|
import '../../../data/services/meeting/meeting_upload_service.dart'; |
|
|
import '../../../data/services/meeting/meeting_upload_service.dart'; |
|
|
import '../../../data/services/network/api.dart'; |
|
|
import '../../../data/services/network/api.dart'; |
|
|
import '../../../routes/app_routes.dart'; |
|
|
import '../../../routes/app_routes.dart'; |
|
|
|
|
|
import 'meeting_record_controller.dart'; |
|
|
import 'meeting_controller.dart'; |
|
|
import 'meeting_controller.dart'; |
|
|
|
|
|
|
|
|
// 会议首页控制器 |
|
|
// 会议首页控制器 |
|
|
@ -199,6 +200,7 @@ class MeetingHomeController extends GetxController { |
|
|
try { |
|
|
try { |
|
|
int addUp = 0; // 新增计数 |
|
|
int addUp = 0; // 新增计数 |
|
|
final appDir = await appDocDir; // 获取应用文档目录 |
|
|
final appDir = await appDocDir; // 获取应用文档目录 |
|
|
|
|
|
final activeRecordingWavName = _getActiveRecordingWavFileName(); |
|
|
|
|
|
|
|
|
final sourceDirs = [ |
|
|
final sourceDirs = [ |
|
|
Directory("${appDir.path}/MeetingAudio/"), // 会议录音目录 |
|
|
Directory("${appDir.path}/MeetingAudio/"), // 会议录音目录 |
|
|
@ -226,16 +228,31 @@ class MeetingHomeController extends GetxController { |
|
|
// 遍历所有文件实体 |
|
|
// 遍历所有文件实体 |
|
|
for (final fileEntity in allFiles) { |
|
|
for (final fileEntity in allFiles) { |
|
|
try { |
|
|
try { |
|
|
|
|
|
final entityName = path.basename(fileEntity.path); |
|
|
|
|
|
if (activeRecordingWavName != null && |
|
|
|
|
|
entityName == activeRecordingWavName) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
final file = File(fileEntity.path); //将文件实体转换为具体文件操作对象 |
|
|
final file = File(fileEntity.path); //将文件实体转换为具体文件操作对象 |
|
|
final filePath = file.path; |
|
|
final filePath = file.path; |
|
|
|
|
|
|
|
|
|
|
|
final fileStat = await file.stat(); //获取文件状态信息,包含修改时间等 |
|
|
|
|
|
if (fileStat.size < 1024) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 使用just_audio库加载音频文件以获取时长 |
|
|
// 使用just_audio库加载音频文件以获取时长 |
|
|
|
|
|
final Duration? duration = |
|
|
await _audioPlayer.setAudioSource(AudioSource.file(filePath)); |
|
|
await _audioPlayer.setAudioSource(AudioSource.file(filePath)); |
|
|
int seconds = |
|
|
final Duration? effectiveDuration = duration ?? _audioPlayer.duration; |
|
|
_audioPlayer.duration?.inSeconds ?? 0; //获取音频时长(秒),若为空则设为0 |
|
|
final int durationMs = effectiveDuration?.inMilliseconds ?? 0; |
|
|
|
|
|
final int seconds = |
|
|
|
|
|
durationMs <= 0 ? 0 : ((durationMs + 999) ~/ 1000); |
|
|
|
|
|
if (seconds <= 0) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 获取文件修改时间 |
|
|
|
|
|
final fileStat = await file.stat(); //获取文件状态信息,包含修改时间等 |
|
|
|
|
|
final creationTime = fileStat.changed.millisecondsSinceEpoch; |
|
|
final creationTime = fileStat.changed.millisecondsSinceEpoch; |
|
|
|
|
|
|
|
|
// 准备新路径 |
|
|
// 准备新路径 |
|
|
@ -312,6 +329,15 @@ class MeetingHomeController extends GetxController { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String? _getActiveRecordingWavFileName() { |
|
|
|
|
|
if (!Get.isRegistered<MeetingRecordController>()) return null; |
|
|
|
|
|
final controller = Get.find<MeetingRecordController>(); |
|
|
|
|
|
if (!controller.isRecording.value) return null; |
|
|
|
|
|
final name = controller.fileName.value; |
|
|
|
|
|
if (name.isEmpty) return null; |
|
|
|
|
|
return '$name.wav'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 新增(2025-11-04):将翻译音频归档到 LocalAudio 并返回新路径(优先 rename,失败再 copy+delete) |
|
|
// 新增(2025-11-04):将翻译音频归档到 LocalAudio 并返回新路径(优先 rename,失败再 copy+delete) |
|
|
Future<String> _archiveTranslatToLocal(String srcPath) async { |
|
|
Future<String> _archiveTranslatToLocal(String srcPath) async { |
|
|
// 获取应用文档目录并确保 LocalAudio 目录存在 |
|
|
// 获取应用文档目录并确保 LocalAudio 目录存在 |
|
|
@ -329,7 +355,7 @@ class MeetingHomeController extends GetxController { |
|
|
|
|
|
|
|
|
if (await File(destPath).exists()) { |
|
|
if (await File(destPath).exists()) { |
|
|
final ts = DateTime.now().millisecondsSinceEpoch; |
|
|
final ts = DateTime.now().millisecondsSinceEpoch; |
|
|
destPath = path.join(destDir.path, '$baseName\_$ts$ext'); |
|
|
destPath = path.join(destDir.path, '${baseName}_$ts$ext'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 中文注释:尝试 rename(更快),失败则 copy + delete |
|
|
// 中文注释:尝试 rename(更快),失败则 copy + delete |
|
|
|