2025-01-09 14:10:10 +08:00
|
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
2025-01-21 10:24:47 +08:00
|
|
|
|
import 'package:star_lock/main/lockDetail/videoLog/videoLog/videoLog_entity.dart';
|
2024-04-25 10:43:56 +08:00
|
|
|
|
import 'package:star_lock/network/api_repository.dart';
|
2023-11-18 10:38:13 +08:00
|
|
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
2025-01-10 14:46:51 +08:00
|
|
|
|
|
2023-11-18 10:38:13 +08:00
|
|
|
|
import 'videoLog_state.dart';
|
|
|
|
|
|
|
2024-04-25 10:43:56 +08:00
|
|
|
|
class VideoLogLogic extends BaseGetXController {
|
2023-11-18 10:38:13 +08:00
|
|
|
|
VideoLogState state = VideoLogState();
|
|
|
|
|
|
|
2024-04-25 10:43:56 +08:00
|
|
|
|
void getLockCloudStorageList() async {
|
|
|
|
|
|
var entity = await ApiRepository.to.getLockCloudStorageList(
|
|
|
|
|
|
lockId: state.getLockId.value,
|
|
|
|
|
|
);
|
|
|
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
2024-04-25 17:33:07 +08:00
|
|
|
|
state.videoLogList.value = entity.data!;
|
2025-01-21 10:24:47 +08:00
|
|
|
|
state.videoLogList.value.forEach((element) {
|
|
|
|
|
|
// 过滤掉 imagesUrl 和 videoUrl 都为 null 或空字符串的项
|
|
|
|
|
|
element.recordList = element.recordList!
|
|
|
|
|
|
.where((record) =>
|
|
|
|
|
|
(record.imagesUrl != null && record.imagesUrl!.isNotEmpty) ||
|
|
|
|
|
|
(record.videoUrl != null && record.videoUrl!.isNotEmpty))
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
// // 为 videoUrl 不为空的项设置封面
|
|
|
|
|
|
// for (var record in element.recordList!) {
|
|
|
|
|
|
// if (record.videoUrl != null && record.videoUrl!.isNotEmpty) {
|
|
|
|
|
|
// _setVideoThumbnail(record); // 设置视频封面
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
});
|
2025-01-20 14:13:56 +08:00
|
|
|
|
|
2024-04-25 10:43:56 +08:00
|
|
|
|
state.videoLogList.refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-04-26 14:48:26 +08:00
|
|
|
|
|
2025-01-21 10:24:47 +08:00
|
|
|
|
// Future<void> _setVideoThumbnail(RecordListData record) async {
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// final thumbnailData = await getVideoThumbnail(record.videoUrl!);
|
|
|
|
|
|
// record.thumbnailData = thumbnailData; // 设置视频封面数据
|
|
|
|
|
|
// } catch (e) {
|
|
|
|
|
|
// print('获取视频封面失败: $e');
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// Future<Uint8List?> getVideoThumbnail(String videoUrl) async {
|
|
|
|
|
|
// final thumbnail = await VideoThumbnail.thumbnailData(
|
|
|
|
|
|
// video: videoUrl,
|
|
|
|
|
|
// imageFormat: ImageFormat.JPEG,
|
|
|
|
|
|
// maxWidth: 128, // 缩略图的最大宽度
|
|
|
|
|
|
// quality: 25, // 缩略图的质量(0-100)
|
|
|
|
|
|
// );
|
|
|
|
|
|
// return thumbnail;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
2024-04-26 14:48:26 +08:00
|
|
|
|
@override
|
|
|
|
|
|
onReady() {
|
|
|
|
|
|
super.onReady();
|
|
|
|
|
|
|
|
|
|
|
|
getLockCloudStorageList();
|
|
|
|
|
|
}
|
2024-04-25 10:43:56 +08:00
|
|
|
|
}
|