Added initial audio library logic.

This commit is contained in:
2025-02-27 00:46:36 -05:00
parent c1a7d23096
commit e2af19d9bb
7 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
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());
}
}