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