通知中心封面图显示
部分界面的信息更新 缓存系统初步引入 即将进入播放列表更新
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// lib/metadata/metadata_reader.dart
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:audio_metadata_reader/audio_metadata_reader.dart' as amr;
|
||||
import 'metadata_model.dart';
|
||||
@@ -7,13 +8,25 @@ import 'metadata_model.dart';
|
||||
class MetadataReader {
|
||||
Future<RawMetadata> readRawMetadata(File file) async {
|
||||
try {
|
||||
// ⭐ getImage: true 读取封面图
|
||||
final meta = amr.readMetadata(file, getImage: true);
|
||||
|
||||
// ⭐ 提取第一张图片
|
||||
debugPrint('📢 [MetadataReader] pictures count: ${meta.pictures.length}');
|
||||
|
||||
Uint8List? artwork;
|
||||
if (meta.pictures != null && meta.pictures!.isNotEmpty) {
|
||||
artwork = meta.pictures.first.bytes;
|
||||
if (meta.pictures.isNotEmpty) {
|
||||
try {
|
||||
final pic = meta.pictures.first;
|
||||
// 尝试获取图片数据,兼容不同字段名
|
||||
artwork = (pic as dynamic).bytes ?? (pic as dynamic).data;
|
||||
if (artwork != null) {
|
||||
debugPrint(
|
||||
'📢 [MetadataReader] artwork extracted: ${artwork.length} bytes');
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('⚠️ [MetadataReader] artwork extraction failed: $e');
|
||||
}
|
||||
} else {
|
||||
debugPrint('📢 [MetadataReader] no artwork found');
|
||||
}
|
||||
|
||||
return RawMetadata(
|
||||
|
||||
Reference in New Issue
Block a user