// Author: Gockner, Simon // Created: 2021-04-08 // Copyright(c) 2021 SimonG. All Rights Reserved. using System.Collections.Generic; using System.Linq; using Lib.Audio.Factories; using Lib.Audio.Interfaces; using NAudio.CoreAudioApi; namespace Lib.Audio { public class ControllableCollector : IControllableCollector { private readonly IControllableFactory _controllableFactory; public ControllableCollector(IControllableFactory controllableFactory) => _controllableFactory = controllableFactory; public List Controllables => CreateControllables(); private List CreateControllables() { MMDeviceEnumerator deviceEnumerator = new(); MMDeviceCollection? audioDevices = deviceEnumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active); return audioDevices.Select(a => _controllableFactory.Create(a.AudioSessionManager.AudioSessionControl)).ToList(); } } }