diff --git a/Lib.Audio/Controllable.cs b/Lib.Audio/Controllable.cs index 83a9f62..3426504 100644 --- a/Lib.Audio/Controllable.cs +++ b/Lib.Audio/Controllable.cs @@ -2,16 +2,19 @@ // Created: 2021-04-07 // Copyright(c) 2021 SimonG. All Rights Reserved. -using System; using Lib.Audio.Interfaces; +using NAudio.CoreAudioApi; namespace Lib.Audio { public class Controllable : IControllable { - public void SetVolume(int volume) - { - throw new NotImplementedException(); - } + private readonly AudioSessionControl _audioSessionControl; + + public Controllable(AudioSessionControl audioSessionControl) => _audioSessionControl = audioSessionControl; + + public void SetVolume(float volume) => _audioSessionControl.SimpleAudioVolume.Volume = volume; + public void Mute() => _audioSessionControl.SimpleAudioVolume.Mute = true; + public void UnMute() => _audioSessionControl.SimpleAudioVolume.Mute = false; } } \ No newline at end of file diff --git a/Lib.Audio/Interfaces/IControllable.cs b/Lib.Audio/Interfaces/IControllable.cs index 13e6b2c..1362f97 100644 --- a/Lib.Audio/Interfaces/IControllable.cs +++ b/Lib.Audio/Interfaces/IControllable.cs @@ -6,6 +6,8 @@ namespace Lib.Audio.Interfaces { public interface IControllable { - void SetVolume(int volume); + void SetVolume(float volume); + void Mute(); + void UnMute(); } } \ No newline at end of file