✨ Bottom player
This commit is contained in:
@ -48,11 +48,11 @@ class AudioServices with WidgetsBindingObserver {
|
||||
duration: track is SourcedTrack
|
||||
? track.sourceInfo.duration
|
||||
: Duration(milliseconds: track.durationMs ?? 0),
|
||||
artUri: Uri.parse(
|
||||
(track.album?.images).asUrlString(
|
||||
placeholder: ImagePlaceholder.albumArt,
|
||||
),
|
||||
),
|
||||
artUri: track.album?.images != null
|
||||
? Uri.parse(
|
||||
(track.album?.images).asUrlString()!,
|
||||
)
|
||||
: null,
|
||||
playable: true,
|
||||
));
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
import 'package:rhythm_box/services/primitive.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:rhythm_box/collections/assets.gen.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
enum ImagePlaceholder {
|
||||
@ -11,24 +9,13 @@ enum ImagePlaceholder {
|
||||
}
|
||||
|
||||
extension SpotifyImageExtensions on List<Image>? {
|
||||
String asUrlString({
|
||||
String? asUrlString({
|
||||
int index = 1,
|
||||
required ImagePlaceholder placeholder,
|
||||
}) {
|
||||
final String placeholderUrl = {
|
||||
ImagePlaceholder.albumArt: Assets.albumPlaceholder.path,
|
||||
ImagePlaceholder.artist: Assets.userPlaceholder.path,
|
||||
ImagePlaceholder.collection: Assets.placeholder.path,
|
||||
ImagePlaceholder.online:
|
||||
"https://avatars.dicebear.com/api/bottts/${PrimitiveUtils.uuid.v4()}.png",
|
||||
}[placeholder]!;
|
||||
|
||||
final sortedImage = this?.sorted((a, b) => a.width!.compareTo(b.width!));
|
||||
|
||||
return sortedImage != null && sortedImage.isNotEmpty
|
||||
? sortedImage[
|
||||
index > sortedImage.length - 1 ? sortedImage.length - 1 : index]
|
||||
.url!
|
||||
: placeholderUrl;
|
||||
return sortedImage?[
|
||||
index > sortedImage.length - 1 ? sortedImage.length - 1 : index]
|
||||
.url;
|
||||
}
|
||||
}
|
||||
|
@ -84,9 +84,7 @@ class WindowsAudioService {
|
||||
albumArtist: track.artists?.firstOrNull?.name ?? "Unknown",
|
||||
artist: track.artists?.asString() ?? "Unknown",
|
||||
album: track.album?.name ?? "Unknown",
|
||||
thumbnail: (track.album?.images).asUrlString(
|
||||
placeholder: ImagePlaceholder.albumArt,
|
||||
),
|
||||
thumbnail: (track.album?.images).asUrlString(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user