64 lines
2.0 KiB
Dart
Executable File
64 lines
2.0 KiB
Dart
Executable File
import 'dart:typed_data';
|
||
|
||
import 'package:star_lock/main/lockDetail/videoLog/videoLog/videoLog_entity.dart';
|
||
import 'package:star_lock/network/api_repository.dart';
|
||
import 'package:star_lock/tools/baseGetXController.dart';
|
||
|
||
import 'videoLog_state.dart';
|
||
|
||
class VideoLogLogic extends BaseGetXController {
|
||
VideoLogState state = VideoLogState();
|
||
|
||
void getLockCloudStorageList() async {
|
||
var entity = await ApiRepository.to.getLockCloudStorageList(
|
||
lockId: state.getLockId.value,
|
||
);
|
||
if (entity.errorCode!.codeIsSuccessful) {
|
||
state.videoLogList.value = entity.data!;
|
||
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); // 设置视频封面
|
||
// }
|
||
// }
|
||
});
|
||
|
||
state.videoLogList.refresh();
|
||
}
|
||
}
|
||
|
||
// 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;
|
||
// }
|
||
|
||
@override
|
||
onReady() {
|
||
super.onReady();
|
||
|
||
getLockCloudStorageList();
|
||
}
|
||
}
|