Files
Melo/lib/library/song_media.dart
T
Hermes (Server)andClaude Haiku 4.5 2712ace665 feat(player): Now Playing als Tab statt Push-Screen, Favoriten-Herz
- songToMediaItem trägt jetzt die Song-UUID in extras['songId'], damit
  Downstream-Code (Favoriten-Button, später Playback-History) den echten
  Song wiederfinden kann statt nur die file-URI zu haben
- NowPlayingScreen: Schließen-Button entfernt (AppBar-leading), da der
  Screen jetzt als eigener Tab läuft statt gepusht zu werden
- FavoriteButton für den aktuellen Song in die AppBar-Actions eingebaut,
  reaktiv über einen verschachtelten StreamBuilder<MediaItem?>; ohne
  gültige songId (z.B. nichts spielt) wird kein Button gerendert

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-18 17:01:31 +02:00

23 lines
694 B
Dart

import 'package:audio_service/audio_service.dart';
import '../player/audio_handler.dart';
import 'database.dart';
MediaItem songToMediaItem(Song s) => MediaItem(
id: Uri.file(s.path).toString(),
title: s.title,
artist: s.artist,
album: s.album,
duration: s.durationMs != null ? Duration(milliseconds: s.durationMs!) : null,
artUri: s.coverPath != null ? Uri.file(s.coverPath!) : null,
extras: {'songId': s.id},
);
/// Spielt [songs] ab [startIndex] ab.
Future<void> playSongs(MeloAudioHandler handler, List<Song> songs, int startIndex) {
return handler.loadPlaylist(
songs.map(songToMediaItem).toList(),
startIndex: startIndex,
);
}