Can choose to play only filtered musics

This commit is contained in:
Pierre HUBERT 2022-10-01 14:50:22 +02:00
parent da1ccb8e3a
commit 1fc43fce78

View File

@ -43,7 +43,9 @@ class _MusicPlayerState extends State<MusicPlayer> {
final List<MusicEntry> _stack = [];
int currMusicPos = 0;
var _showPlaylist = false;
var _showPlaylist = true;
var _playFilteredMusics = false;
final _filterController = fluent.TextEditingController();
MusicsList? _filteredList;
@ -53,8 +55,11 @@ class _MusicPlayerState extends State<MusicPlayer> {
// Automatically choose next music if required
if (currMusicPos >= _stack.length) {
var nextId = rng.nextInt(widget.musicsList.length);
_stack.add(widget.musicsList[nextId]);
var list = _playFilteredMusics
? _filteredList ?? widget.musicsList
: widget.musicsList;
var nextId = rng.nextInt(list.length);
_stack.add(list[nextId]);
}
return _stack[currMusicPos];
@ -341,7 +346,7 @@ class _MusicPlayerState extends State<MusicPlayer> {
return ListTile(
leading: RoundedImage(
child: CoverImage(
delayLoading: const Duration(seconds: 3),
delayLoading: const Duration(seconds: 2),
music: music,
width: 50,
height: 50,
@ -359,6 +364,13 @@ class _MusicPlayerState extends State<MusicPlayer> {
itemCount: (_filteredList ?? widget.musicsList).length,
),
),
ListTile(
leading: fluent.ToggleSwitch(
checked: _playFilteredMusics,
onChanged: (v) => setState(() => _playFilteredMusics = v),
),
title: const Text("Play only filtered musics"),
)
],
);
}