Files
harmonia/Harmonia.Core/Library/IAudioLibrary.cs

67 lines
1.5 KiB
C#

namespace Harmonia.Core.Library;
public interface IAudioLibrary
{
void AddLocation(string path);
void RemoveLocation(string path);
void RemoveLocations(string[] paths);
void Scan(string path);
void Scan(string[] paths);
event EventHandler<EventArgs>? LocationAdded;
event EventHandler<EventArgs>? LocationRemoved;
event EventHandler<EventArgs>? ScanStarted;
event EventHandler<EventArgs>? ScanFinished;
}
public class AudioLibrary : IAudioLibrary
{
private readonly List<string> _locations = [];
public event EventHandler<EventArgs>? LocationAdded;
public event EventHandler<EventArgs>? LocationRemoved;
public event EventHandler<EventArgs>? ScanStarted;
public event EventHandler<EventArgs>? ScanFinished;
public void AddLocation(string path)
{
if (_locations.Contains(path))
return;
// TODO: CHeck for subpaths
_locations.Add(path);
LocationAdded?.Invoke(this, new EventArgs());
}
public void RemoveLocation(string path)
{
RemoveLocations([path]);
}
public void RemoveLocations(string[] paths)
{
foreach (string path in paths)
{
if (_locations.Contains(path) == false)
continue;
}
LocationRemoved?.Invoke(this, new EventArgs());
}
public void Scan(string path)
{
Scan([path]);
}
public void Scan(string[] paths)
{
ScanStarted?.Invoke(this, new EventArgs());
ScanFinished?.Invoke(this, new EventArgs());
}
}