mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using CSCore.SoundOut;
|
|
|
|
namespace RedBookPlayer.Models.Hardware.Windows
|
|
{
|
|
public class AudioBackend : IAudioBackend
|
|
{
|
|
/// <summary>
|
|
/// Sound output instance
|
|
/// </summary>
|
|
private ALSoundOut _soundOut;
|
|
|
|
public AudioBackend() { }
|
|
|
|
public AudioBackend(PlayerSource source)
|
|
{
|
|
_soundOut = new ALSoundOut(100);
|
|
_soundOut.Initialize(source);
|
|
}
|
|
|
|
#region IAudioBackend Implementation
|
|
|
|
/// <inheritdoc/>
|
|
public void Pause() => _soundOut.Pause();
|
|
|
|
/// <inheritdoc/>
|
|
public void Play() => _soundOut.Play();
|
|
|
|
/// <inheritdoc/>
|
|
public void Stop() => _soundOut.Stop();
|
|
|
|
/// <inheritdoc/>
|
|
public PlayerState GetPlayerState()
|
|
{
|
|
return (_soundOut?.PlaybackState) switch
|
|
{
|
|
PlaybackState.Paused => PlayerState.Paused,
|
|
PlaybackState.Playing => PlayerState.Playing,
|
|
PlaybackState.Stopped => PlayerState.Stopped,
|
|
_ => PlayerState.NoDisc,
|
|
};
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public void SetVolume(float volume)
|
|
{
|
|
if (_soundOut != null)
|
|
_soundOut.Volume = volume;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |