using System.Collections.Generic; using LibMpc.Types; namespace LibMpc { public partial class Commands { /// /// https://www.musicpd.org/doc/protocol/output_commands.html /// public class Output { /// /// Turns an output off. /// public class DisableOutput : IMpcCommand { private readonly int _outputId; public DisableOutput(int outputId) { _outputId = outputId; } public string Value => string.Join(" ", "disableoutput", _outputId); public string FormatResponse(IList> response) { // Response should be empty. return string.Join(", ", response); } } /// /// Turns an output on. /// public class EnableOutput : IMpcCommand { private readonly int _outputId; public EnableOutput(int outputId) { _outputId = outputId; } public string Value => string.Join(" ", "enableoutput", _outputId); public string FormatResponse(IList> response) { // Response should be empty. return string.Join(", ", response); } } /// /// Turns an output on or off, depending on the current state. /// public class ToggleOutput : IMpcCommand { private readonly int _outputId; public ToggleOutput(int outputId) { _outputId = outputId; } public string Value => string.Join(" ", "toggleoutput", _outputId); public string FormatResponse(IList> response) { // Response should be empty. return string.Join(", ", response); } } /// /// Shows information about all outputs. /// public class Outputs : IMpcCommand> { public string Value => "outputs"; public IEnumerable FormatResponse(IList> response) { var result = new List(); for (var i = 0; i < response.Count; i += 3) { var outputId = int.Parse(response[i].Value); var outputName = response[i + 1].Value; var outputEnabled = response[i + 2].Value == "1"; result.Add(new MpdOutput(outputId, outputName, outputEnabled)); } return result; } } } } }