Enabled image file scan (#151)
This commit is contained in:
parent
ec36fcd105
commit
a750a52e2e
1 changed files with 20 additions and 15 deletions
|
@ -23,7 +23,7 @@ import 'local_music_fetcher.dart';
|
||||||
import 'music_data_source_contract.dart';
|
import 'music_data_source_contract.dart';
|
||||||
import 'settings_data_source.dart';
|
import 'settings_data_source.dart';
|
||||||
|
|
||||||
const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png'];
|
const IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png'];
|
||||||
|
|
||||||
class LocalMusicFetcherImpl implements LocalMusicFetcher {
|
class LocalMusicFetcherImpl implements LocalMusicFetcher {
|
||||||
LocalMusicFetcherImpl(
|
LocalMusicFetcherImpl(
|
||||||
|
@ -140,22 +140,27 @@ class LocalMusicFetcherImpl implements LocalMusicFetcher {
|
||||||
albumIdMap[albumString] = albumId;
|
albumIdMap[albumString] = albumId;
|
||||||
newAlbumId = max(newAlbumId, albumId + 1);
|
newAlbumId = max(newAlbumId, albumId + 1);
|
||||||
|
|
||||||
final Uint8List? albumArt = songData.picture?.data;
|
Uint8List? albumArt = songData.picture?.data;
|
||||||
|
|
||||||
// fallback to get albumArt
|
// fallback to get albumArt
|
||||||
// TODO: enable when everything else works as expected
|
if (albumArt == null) {
|
||||||
// if (albumArt == null) {
|
// get directory of song and look for image files
|
||||||
// // get directory of song and look for image files
|
final images = await songFile.parent
|
||||||
// final images = await songFile.parent
|
.list(recursive: false, followLinks: false)
|
||||||
// .list(recursive: false, followLinks: false)
|
.where((item) =>
|
||||||
// .where((item) =>
|
FileSystemEntity.isFileSync(item.path) &&
|
||||||
// FileSystemEntity.isFileSync(item.path) &&
|
IMAGE_EXTENSIONS.contains(p.extension(item.path).toLowerCase()))
|
||||||
// IMAGE_EXTENSIONS.contains(
|
.asyncMap((item) => File(item.path))
|
||||||
// p.extension(item.path).toLowerCase().substring(1)))
|
.toList();
|
||||||
// .asyncMap((item) => File(item.path))
|
for (final image in images) {
|
||||||
// .toList();
|
try {
|
||||||
// if (images.isNotEmpty) albumArt = images.first.readAsBytesSync();
|
albumArt = image.readAsBytesSync();
|
||||||
// }
|
break;
|
||||||
|
} catch (e) {
|
||||||
|
_log.e('Could not read image file: ${image.path}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (albumArt != null) {
|
if (albumArt != null) {
|
||||||
albumArtMap[albumId] = await cacheAlbumArt(albumArt, albumId);
|
albumArtMap[albumId] = await cacheAlbumArt(albumArt, albumId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue