Navidrome-Integration, Widgets (Recent + Tag-Statistik)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import '../database/db_helper.dart';
|
||||
import '../models/song.dart';
|
||||
import '../models/playlist.dart';
|
||||
|
||||
class PlaylistService {
|
||||
final DbHelper _db = DbHelper();
|
||||
|
||||
Future<List<Playlist>> allePlaylists() async {
|
||||
final rows = await _db.allePlaylists();
|
||||
final listen = <Playlist>[];
|
||||
for (final r in rows) {
|
||||
final id = r['id'] as int;
|
||||
final songs = await _db.songsDerPlaylist(id);
|
||||
listen.add(Playlist.fromMap(r, songCount: songs.length));
|
||||
}
|
||||
return listen;
|
||||
}
|
||||
|
||||
Future<int> erstellen(String name) async {
|
||||
return _db.playlistErstellen(name);
|
||||
}
|
||||
|
||||
Future<List<Song>> songs(int playlistId) async {
|
||||
return _db.songsDerPlaylist(playlistId);
|
||||
}
|
||||
|
||||
Future<void> songHinzufuegen(int playlistId, int songId) async {
|
||||
final songs = await _db.songsDerPlaylist(playlistId);
|
||||
await _db.songZurPlaylist(playlistId, songId, songs.length);
|
||||
}
|
||||
|
||||
Future<void> songEntfernen(int playlistId, int songId) async {
|
||||
await _db.songAusPlaylistEntfernen(playlistId, songId);
|
||||
}
|
||||
|
||||
Future<bool> istInPlaylist(int playlistId, int songId) async {
|
||||
final songs = await _db.songsDerPlaylist(playlistId);
|
||||
return songs.any((s) => s.id == songId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user