Cleaning
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -35,31 +33,20 @@ namespace unison
|
||||
return;
|
||||
|
||||
SongList.Clear();
|
||||
|
||||
int song = _mpd.GetStats().Songs;
|
||||
|
||||
Debug.WriteLine("before search command / song == " + song);
|
||||
|
||||
IEnumerable<IMpdFile> response = await _mpd.SafelySendCommandAsync(new SearchCommand(filter, 0, song + 1));
|
||||
|
||||
Debug.WriteLine("got response => " + response.Count());
|
||||
|
||||
foreach (IMpdFile file in response)
|
||||
{
|
||||
SongList.Add(file.Path);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddToQueueRandom(int SongNumber, CancellationToken token)
|
||||
{
|
||||
Debug.WriteLine("Add To Queue Random");
|
||||
|
||||
if (token.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
int AddedSongs = 0;
|
||||
|
||||
Debug.WriteLine("song to add => " + SongNumber);
|
||||
|
||||
var commandList = new CommandList();
|
||||
int songTotal = _mpd.GetStats().Songs;
|
||||
|
||||
@ -75,25 +62,18 @@ namespace unison
|
||||
}
|
||||
|
||||
await _mpd.SafelySendCommandAsync(commandList);
|
||||
|
||||
Debug.WriteLine("Add To Queue Random - finished with " + AddedSongs + " songs");
|
||||
}
|
||||
|
||||
public async Task AddToQueueFilter(int SongNumber, CancellationToken token)
|
||||
{
|
||||
Debug.WriteLine("Add To Queue Filter - start");
|
||||
|
||||
if (token.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
int AddedSongs = 0;
|
||||
|
||||
Debug.WriteLine("song to add => " + SongNumber);
|
||||
// more (or equal) requested songs than available => add everything
|
||||
if (SongNumber >= SongList.Count)
|
||||
{
|
||||
Trace.WriteLine("more requested songs than available => add everything");
|
||||
|
||||
var commandList = new CommandList();
|
||||
foreach (string path in SongList)
|
||||
{
|
||||
@ -107,8 +87,6 @@ namespace unison
|
||||
// we add unique indexes until we reach the requested amount
|
||||
else
|
||||
{
|
||||
Trace.WriteLine("more available songs than requested");
|
||||
|
||||
HashSet<int> SongIndex = new();
|
||||
while (SongIndex.Count < SongNumber)
|
||||
{
|
||||
@ -125,8 +103,6 @@ namespace unison
|
||||
|
||||
await _mpd.SafelySendCommandAsync(commandList);
|
||||
}
|
||||
|
||||
Debug.WriteLine("Add To Queue Filter - finished");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user