using CSCore.SoundOut; namespace RedBookPlayer.Models.Audio.Windows { public class AudioBackend : IAudioBackend { /// /// Sound output instance /// private readonly ALSoundOut _soundOut; public AudioBackend() { } public AudioBackend(PlayerSource source) { _soundOut = new ALSoundOut(100); _soundOut.Initialize(source); } #region IAudioBackend Implementation /// public void Pause() => _soundOut.Pause(); /// public void Play() => _soundOut.Play(); /// public void Stop() => _soundOut.Stop(); /// public PlayerState GetPlayerState() { return (_soundOut?.PlaybackState) switch { PlaybackState.Paused => PlayerState.Paused, PlaybackState.Playing => PlayerState.Playing, PlaybackState.Stopped => PlayerState.Stopped, _ => PlayerState.NoDisc, }; } /// public void SetVolume(float volume) { if(_soundOut != null) _soundOut.Volume = volume; } #endregion } }