Added AvaloniaUI project.

This commit is contained in:
2025-03-01 17:03:06 -05:00
parent f78fe6fa2b
commit fc28004c89
25 changed files with 616 additions and 2 deletions

View File

@@ -86,6 +86,8 @@ public class BassAudioEngine : IAudioEngine, IDisposable
public BassAudioEngine()
{
BassLoader.Initialize();
_mediaPlayer = new MediaPlayer();
_mediaPlayer.MediaLoaded += OnMediaLoaded;
_mediaPlayer.MediaFailed += OnPlaybackStopped;

View File

@@ -0,0 +1,22 @@
using System.Runtime.InteropServices;
namespace Harmonia.Core.Engine;
public static class BassLoader
{
public static void Initialize()
{
string archFolder = Environment.Is64BitProcess ? "x64" : "x86";
string bassPluginPath = Path.Combine("Plugins", "Bass", "Win32", archFolder);
LoadLibrary(bassPluginPath, "bass.dll");
LoadLibrary(bassPluginPath, "bassflac.dll");
}
private static void LoadLibrary(string bassPluginPath, string resourceName)
{
string resourcePath = Path.Combine(bassPluginPath, resourceName);
NativeLibrary.Load(resourcePath);
}
}

View File

@@ -17,4 +17,19 @@
<PackageReference Include="TagLibSharp" Version="2.3.0" />
</ItemGroup>
<ItemGroup>
<None Update="Plugins\Bass\Win32\x64\bass.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Plugins\Bass\Win32\x64\bassflac.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Plugins\Bass\Win32\x86\bass.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Plugins\Bass\Win32\x86\bassflac.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -36,6 +36,7 @@ public class AudioPlayer : IAudioPlayer
{
_playingSong = value;
NotifyPropertyChanged(nameof(PlayingSong));
PlayingSongChanged?.Invoke(this, new());
}
}
@@ -111,6 +112,7 @@ public class AudioPlayer : IAudioPlayer
protected virtual int PreviousSongSecondsThreshold => 5;
public event EventHandler? PlayingSongChanged;
public event PropertyChangedEventHandler? PropertyChanged;
public AudioPlayer(IAudioEngine audioEngine, IPlaylistRepository playlistRepository)

View File

@@ -24,5 +24,6 @@ public interface IAudioPlayer
Task PreviousAsync();
Task NextAsync();
event EventHandler PlayingSongChanged;
event PropertyChangedEventHandler PropertyChanged;
}