Added initial audio library logic.
This commit is contained in:
67
Harmonia.Core/Library/IAudioLibrary.cs
Normal file
67
Harmonia.Core/Library/IAudioLibrary.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user