feat: enhance audio playback features and UI, including audio player dialog and improved file size handling

This commit is contained in:
HueByte
2026-02-21 19:50:09 +01:00
parent 3e03a77aeb
commit de34fb43b9
7 changed files with 485 additions and 6 deletions
@@ -8,6 +8,14 @@ public class AudioPlaybackService
private readonly Player _player = new();
public bool IsPlaying => _player.Playing;
public bool IsPaused => _player.Paused;
public event EventHandler? PlaybackFinished;
public AudioPlaybackService()
{
_player.PlaybackFinished += (s, e) => PlaybackFinished?.Invoke(this, EventArgs.Empty);
}
public async Task PlayAsync(string filePath)
{
@@ -24,6 +32,32 @@ public class AudioPlaybackService
}
}
public async Task PauseAsync()
{
try
{
if (_player.Playing && !_player.Paused)
await _player.Pause();
}
catch (Exception ex)
{
Log.Warning(ex, "Failed to pause audio playback");
}
}
public async Task ResumeAsync()
{
try
{
if (_player.Paused)
await _player.Resume();
}
catch (Exception ex)
{
Log.Warning(ex, "Failed to resume audio playback");
}
}
public async Task StopAsync()
{
try
@@ -36,4 +70,16 @@ public class AudioPlaybackService
Log.Warning(ex, "Failed to stop audio playback");
}
}
public async Task SetVolumeAsync(byte volume)
{
try
{
await _player.SetVolume(Math.Min(volume, (byte)100));
}
catch (Exception ex)
{
Log.Warning(ex, "Failed to set audio volume");
}
}
}