22 lines
662 B
Dart
22 lines
662 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,
|
|
);
|
|
|
|
/// Spielt [songs] ab [startIndex] ab.
|
|
Future<void> playSongs(MeloAudioHandler handler, List<Song> songs, int startIndex) {
|
|
return handler.loadPlaylist(
|
|
songs.map(songToMediaItem).toList(),
|
|
startIndex: startIndex,
|
|
);
|
|
}
|