You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.6 KiB
45 lines
1.6 KiB
// Author: Gockner, Simon
|
|
// Created: 2021-04-07
|
|
// Copyright(c) 2021 SimonG. All Rights Reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Lib.Audio.Interfaces;
|
|
using NAudio.CoreAudioApi;
|
|
|
|
namespace Lib.Audio
|
|
{
|
|
public class Controllable : IControllable
|
|
{
|
|
private readonly List<AudioSessionControl> _audioSessionControls;
|
|
|
|
public Controllable(List<AudioSessionControl> audioSessionControls, string executablePath, string name)
|
|
{
|
|
_audioSessionControls = audioSessionControls;
|
|
ExecutablePath = executablePath;
|
|
Name = name;
|
|
}
|
|
|
|
public Controllable(string executablePath)
|
|
{
|
|
IsValid = false;
|
|
|
|
ExecutablePath = executablePath;
|
|
Name = "";
|
|
_audioSessionControls = new List<AudioSessionControl>();
|
|
}
|
|
|
|
public bool IsValid { get; set; } = true;
|
|
public string ExecutablePath { get; }
|
|
public string Name { get; }
|
|
public string? IconPath => _audioSessionControls.FirstOrDefault(c => !string.IsNullOrEmpty(c.IconPath))?.IconPath; //FixMe
|
|
|
|
public void SetVolume(float volume) => _audioSessionControls.ForEach(c => c.SimpleAudioVolume.Volume = volume);
|
|
public float GetVolume() => _audioSessionControls[0].SimpleAudioVolume.Volume; //TODO: Can we always take 0?
|
|
|
|
public void Mute() => _audioSessionControls.ForEach(c => c.SimpleAudioVolume.Mute = true);
|
|
public void UnMute() => _audioSessionControls.ForEach(c => c.SimpleAudioVolume.Mute = false);
|
|
|
|
public override string ToString() => Name;
|
|
}
|
|
} |