1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2025-07-18 05:27:37 +00:00

Restructured commands

This commit is contained in:
Kim Hugener-Ohlsen
2018-09-04 19:45:21 +02:00
parent 1f59105d4e
commit 393df7ca9a
95 changed files with 4733 additions and 1045 deletions

View File

@ -29,12 +29,12 @@
private static async Task SendCommand(string command)
{
var response = await Mpc.SendAsync(_ => new PassthroughCommand(command));
var response = await Mpc.SendAsync(new PassthroughCommand(command));
TestOutput.WriteLine(response);
}
private static async Task SendCommand<T>(IMpcCommand<T> command)
{
var response = await Mpc.SendAsync(_ => command);
var response = await Mpc.SendAsync(command);
TestOutput.WriteLine(response);
}

View File

@ -3,7 +3,6 @@ namespace MpcNET.Test
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MpcNET.Commands;
using MpcNET.Tags;
public partial class LibMpcTest
@ -11,7 +10,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task ListAllTest()
{
var response = await Mpc.SendAsync(commands => commands.Database.ListAll());
var response = await Mpc.SendAsync(new Commands.Database.ListAllCommand());
TestOutput.WriteLine("ListAllTest Result:");
TestOutput.WriteLine(response);
@ -22,7 +21,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task FindGenreTest()
{
var response = await Mpc.SendAsync(commands => commands.Database.Find(MpdTags.Genre, "soundfx"));
var response = await Mpc.SendAsync(new Commands.Database.FindCommand(MpdTags.Genre, "soundfx"));
TestOutput.WriteLine("FindGenreTest Result:");
TestOutput.WriteLine(response);

View File

@ -9,10 +9,10 @@ namespace MpcNET.Test
[TestMethod]
public async Task DisableOutputTest()
{
var responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
var responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(0)).IsEnabled);
var response = await Mpc.SendAsync(commands => commands.Output.DisableOutput(0));
var response = await Mpc.SendAsync(new Commands.Output.DisableOutputCommand(0));
TestOutput.WriteLine("DisableOutputTest Result:");
TestOutput.WriteLine(response);
@ -20,18 +20,18 @@ namespace MpcNET.Test
Assert.IsTrue(response.Response.Content.Equals(string.Empty));
Assert.IsTrue(response.Response.Result.Status.Equals("OK"));
responseOutputs = await Mpc.SendAsync(c => c.Output.Outputs());
responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(0)).IsEnabled);
}
[TestMethod]
public async Task EnableOutputTest()
{
var responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
var responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
// By default should be disable from mpd.config
Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(1)).IsEnabled);
var response = await Mpc.SendAsync(commands => commands.Output.EnableOutput(1));
var response = await Mpc.SendAsync(new Commands.Output.EnableOutputCommand(1));
TestOutput.WriteLine("EnableOutputTest Result:");
TestOutput.WriteLine(response);
@ -39,17 +39,17 @@ namespace MpcNET.Test
Assert.IsTrue(response.Response.Content.Equals(string.Empty));
Assert.IsTrue(response.Response.Result.Status.Equals("OK"));
responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(1)).IsEnabled);
}
[TestMethod]
public async Task ToggleOutputTest()
{
var responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
var responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(2)).IsEnabled);
var response = await Mpc.SendAsync(commands => commands.Output.ToggleOutput(2));
var response = await Mpc.SendAsync(new Commands.Output.ToggleOutputCommand(2));
TestOutput.WriteLine("ToggleOutputTest Result:");
TestOutput.WriteLine(response);
@ -57,14 +57,14 @@ namespace MpcNET.Test
Assert.IsTrue(response.Response.Content.Equals(string.Empty));
Assert.IsTrue(response.Response.Result.Status.Equals("OK"));
responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(2)).IsEnabled);
}
[TestMethod]
public async Task LisOutputsTest()
{
var response = await Mpc.SendAsync(commands => commands.Output.Outputs());
var response = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
TestOutput.WriteLine("LisOutputsTest Result:");
TestOutput.WriteLine(response);

View File

@ -13,7 +13,7 @@
[DataRow("_My Playlist", 5)]
public async Task ListPlaylistTest(string playlistName, int numberOfFiles)
{
var response = await Mpc.SendAsync(commands => commands.StoredPlaylist.GetContent(playlistName));
var response = await Mpc.SendAsync(new Commands.Playlist.ListPlaylistCommand(playlistName));
TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:");
TestOutput.WriteLine(response);
@ -27,7 +27,7 @@
[DataRow("_My Playlist", 5)]
public async Task ListPlaylistInfoTest(string playlistName, int numberOfFiles)
{
var response = await Mpc.SendAsync(commands => commands.StoredPlaylist.GetContentWithMetadata(playlistName));
var response = await Mpc.SendAsync(new Commands.Playlist.ListPlaylistInfoCommand(playlistName));
TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:");
TestOutput.WriteLine(response);
@ -41,7 +41,7 @@
[TestMethod]
public async Task ListPlaylistsTest()
{
var response = await Mpc.SendAsync(commands => commands.StoredPlaylist.GetAll());
var response = await Mpc.SendAsync(new Commands.Playlist.ListPlaylistsCommand());
TestOutput.WriteLine($"ListPlaylistsTest Result:");
TestOutput.WriteLine(response);
@ -117,57 +117,57 @@
private async Task Check_Empty_Queue()
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.GetAllSongsInfo());
var message = await Mpc.SendAsync(new Commands.Playlist.PlaylistCommand());
Assert.IsTrue(message.HasSuccessResponse());
Assert.IsFalse(message.Response.Content.Any());
}
private async Task Load_Playlist(string playlistName)
{
var message = await Mpc.SendAsync(commands => commands.StoredPlaylist.Load(playlistName));
var message = await Mpc.SendAsync(new Commands.Playlist.LoadCommand(playlistName));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Clear_Queue()
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.Clear());
var message = await Mpc.SendAsync(new Commands.Playlist.ClearCommand());
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Check_Queue_HasSongs(int nrOfSongs)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.GetAllSongsInfo());
var message = await Mpc.SendAsync(new Commands.Playlist.PlaylistCommand());
Assert.IsTrue(message.HasSuccessResponse());
Assert.IsTrue(message.Response.Content.Count() == nrOfSongs);
}
private async Task Add_Directory(string directory)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.AddDirectory(directory));
var message = await Mpc.SendAsync(new Commands.Playlist.AddCommand(directory));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Add_File(string file)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.AddSong(file));
var message = await Mpc.SendAsync(new Commands.Playlist.AddIdCommand(file));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Remove_Position(int position)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.RemoveSongByPosition(position));
var message = await Mpc.SendAsync(new Commands.Playlist.DeleteCommand(position));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Remove_Id(int songId)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.RemoveSongById(songId));
var message = await Mpc.SendAsync(new Commands.Playlist.DeleteIdCommand(songId));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task<int> Get_Song_Id()
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.GetAllSongMetadata());
var message = await Mpc.SendAsync(new Commands.Playlist.PlaylistInfoCommand());
return message.Response.Content.Single().Id;
}
}

View File

@ -10,7 +10,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task CommandsTest()
{
var response = await Mpc.SendAsync(commands => commands.Reflection.Commands());
var response = await Mpc.SendAsync(new Commands.Reflection.CommandsCommand());
TestOutput.WriteLine($"CommandsTest (commands: {response.Response.Content.Count()}) Result:");
TestOutput.WriteLine(response);
@ -28,7 +28,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task TagTypesTest()
{
var response = await Mpc.SendAsync(commands => commands.Reflection.TagTypes());
var response = await Mpc.SendAsync(new Commands.Reflection.TagTypesCommand());
TestOutput.WriteLine("TagTypesTest Result:");
TestOutput.WriteLine(response);
@ -39,7 +39,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task UrlHandlersTest()
{
var response = await Mpc.SendAsync(commands => commands.Reflection.UrlHandlers());
var response = await Mpc.SendAsync(new Commands.Reflection.UrlHandlersCommand());
TestOutput.WriteLine($"UrlHandlersTest (handlers: {response.Response.Content.Count()}) Result:");
TestOutput.WriteLine(response);
@ -55,7 +55,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task DecodersTest()
{
var response = await Mpc.SendAsync(commands => commands.Reflection.Decoders());
var response = await Mpc.SendAsync(new Commands.Reflection.DecodersCommand());
TestOutput.WriteLine($"DecodersTest (decoders: {response.Response.Content.Count()}) Result:");
TestOutput.WriteLine(response);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\kim\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\kim\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
]
}
}

View File

@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "netcoreapp2.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "2.0.0"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
teaspoon-stirring-mug-of-coffee.mp3
whistle-kettle-boiling.mp3
wine-glass-double-chink-clink-cheers.mp3
Directory With Spaces/coin-spin-light.mp3
Directory With Spaces/finger-snap-click.mp3

View File

@ -0,0 +1,3 @@
A long name directory with some spaces/pouring-water-into-mug-of-coffee.mp3
A long name directory with some spaces/Sub Directory Two/short-trouser-pants-zip-closing.mp3
Directory/2-Kids-Laughing.mp3

View File

@ -0,0 +1,5 @@
A long name directory with some spaces/Ghost-Sounds.mp3
Directory/ambient-noise-server-room.mp3
Directory With Spaces/SubDirectory One/central-locking-Ford-Mondeo-Mk-3.mp3
_My Directory/gas-fire-lighting.mp3
A long name directory with some spaces/Sub Directory Two/starting-engine-Ford-Mondeo-Mk-3-diesel.mp3

View File

@ -0,0 +1 @@
mpd.exe mpd.conf -v

View File

@ -0,0 +1,30 @@
log_file "mpd_log.txt"
db_file "mpd.db"
bind_to_address "any"
music_directory "Music"
playlist_directory "Playlists"
port "6600"
audio_output {
type "null"
name "Enabled output to be disabled"
enabled "true"
mixer_type "none"
}
audio_output {
type "null"
name "Disabled output to be enabled"
enabled "false"
mixer_type "none"
}
audio_output {
type "null"
name "Enabled output to be toggled"
enabled "true"
mixer_type "none"
}

View File

@ -0,0 +1,163 @@
info_begin
format: 1
mpd_version: 0.17.4
fs_charset: cp1252
tag: Artist
tag: ArtistSort
tag: Album
tag: AlbumArtist
tag: AlbumArtistSort
tag: Title
tag: Track
tag: Name
tag: Genre
tag: Date
tag: Composer
tag: Performer
tag: Disc
tag: MUSICBRAINZ_ARTISTID
tag: MUSICBRAINZ_ALBUMID
tag: MUSICBRAINZ_ALBUMARTISTID
tag: MUSICBRAINZ_TRACKID
info_end
directory: A long name directory with some spaces
mtime: 1482142041
begin: A long name directory with some spaces
directory: Sub Directory Two
mtime: 1482142041
begin: A long name directory with some spaces/Sub Directory Two
song_begin: short-trouser-pants-zip-closing.mp3
Time: 1
Artist: Geek & Dummy
Title: Sound effect: short trouser pants zip closing
Date: 2013
Date: 2013
mtime: 1481623577
song_end
song_begin: starting-engine-Ford-Mondeo-Mk-3-diesel.mp3
Time: 6
Artist: Geek & Dummy
Title: Sound effect: starting engine - Ford Mondeo Mk 3 diesel
Album: Geek & Dummy Sound Library
Date: 2014
Genre: soundfx
mtime: 1481623577
song_end
end: A long name directory with some spaces/Sub Directory Two
song_begin: pouring-water-into-mug-of-coffee.mp3
Time: 4
Artist: Geek & Dummy
Title: Sound effect: pouring water into mug of coffee
Date: 2013
Date: 2013
mtime: 1481623577
song_end
song_begin: Ghost-Sounds.mp3
Time: 95
Artist: Geek & Dummy
Title: Sound effect: ghostly haunted house (bells, ghostly laughs & knives sharpened)
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481623577
song_end
end: A long name directory with some spaces
directory: Directory
mtime: 1482142041
begin: Directory
song_begin: 2-Kids-Laughing.mp3
Time: 30
Artist: Geek & Dummy
Title: Sound effect: two kids laughing
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481623577
song_end
song_begin: ambient-noise-server-room.mp3
Time: 71
Artist: Geek & Dummy
Title: Sound effect: ambient noise - server room
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481623577
song_end
end: Directory
directory: Directory With Spaces
mtime: 1482142041
begin: Directory With Spaces
directory: SubDirectory One
mtime: 1482142041
begin: Directory With Spaces/SubDirectory One
song_begin: central-locking-Ford-Mondeo-Mk-3.mp3
Time: 5
Artist: Geek & Dummy
Title: Sound effect: central locking - Ford Mondeo Mk 3
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481623577
song_end
end: Directory With Spaces/SubDirectory One
song_begin: coin-spin-light.mp3
Time: 5
Artist: Geek & Dummy
Title: Sound effect: coin spin (light coin)
Date: 2013
Date: 2013
mtime: 1481623577
song_end
song_begin: finger-snap-click.mp3
Time: 0
Artist: Geek & Dummy
Title: Sound effect: finger snap/click
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481623577
song_end
end: Directory With Spaces
directory: _My Directory
mtime: 1482142041
begin: _My Directory
song_begin: gas-fire-lighting.mp3
Time: 58
Artist: Geek & Dummy
Title: Sound effect: gas fire lighting and warming up
Album: Geek & Dummy Sound Library
Date: 2014
Date: 2014
Genre: soundfx
mtime: 1481623577
song_end
end: _My Directory
song_begin: teaspoon-stirring-mug-of-coffee.mp3
Time: 4
Artist: Geek & Dummy
Title: Sound effect: teaspoon stirring mug of coffee
Date: 2013
Date: 2013
mtime: 1481623577
song_end
song_begin: whistle-kettle-boiling.mp3
Time: 36
Artist: Geek & Dummy
Title: Sound effect: whistle kettle boiling
Date: 2013
Date: 2013
mtime: 1481623577
song_end
song_begin: wine-glass-double-chink-clink-cheers.mp3
Time: 1
Artist: Geek & Dummy
Title: Sound effect: wine glass double chink/clink/cheers
Date: 2013
Date: 2013
mtime: 1481623577
song_end

View File

@ -0,0 +1,88 @@
Apr 12 14:17 : client: [0] opened from 127.0.0.1:65192
Apr 12 14:17 : client: [0] expired
Apr 12 14:17 : client: [0] closed
Apr 12 14:17 : client: [1] opened from 127.0.0.1:65193
Apr 12 14:17 : client: [1] expired
Apr 12 14:17 : client: [1] closed
Apr 12 14:17 : client: [2] opened from 127.0.0.1:65194
Apr 12 14:17 : client: [2] expired
Apr 12 14:17 : client: [2] closed
Apr 12 14:17 : client: [3] opened from 127.0.0.1:65195
Apr 12 14:17 : client: [3] expired
Apr 12 14:17 : client: [3] closed
Apr 12 14:18 : client: [4] opened from 127.0.0.1:65196
Apr 12 14:18 : client: [4] expired
Apr 12 14:18 : client: [4] closed
Apr 12 14:18 : client: [5] opened from 127.0.0.1:65203
Apr 12 14:18 : client: [5] expired
Apr 12 14:18 : client: [5] closed
Apr 12 14:19 : client: [6] opened from 127.0.0.1:65204
Apr 12 14:19 : client: [6] process command "stats"
Apr 12 14:19 : client: [6] command returned 0
Apr 12 14:19 : client: [6] expired
Apr 12 14:19 : client: [6] closed
Apr 12 14:20 : client: [7] opened from 127.0.0.1:65220
Apr 12 14:20 : client: [7] process command "stats"
Apr 12 14:20 : client: [7] command returned 0
Apr 12 14:20 : client: [7] expired
Apr 12 14:20 : client: [7] closed
Apr 12 14:20 : client: [8] opened from 127.0.0.1:65221
Apr 12 14:20 : client: [8] process command "status"
Apr 12 14:20 : client: [8] command returned 0
Apr 12 14:20 : client: [8] expired
Apr 12 14:20 : client: [8] closed
Apr 12 14:23 : client: [9] opened from 127.0.0.1:65226
Apr 12 14:23 : client: [9] process command "stats"
Apr 12 14:23 : client: [9] command returned 0
Apr 12 14:23 : client: [9] expired
Apr 12 14:23 : client: [9] closed
Apr 12 14:23 : client: [10] opened from 127.0.0.1:65227
Apr 12 14:23 : client: [10] process command "stats"
Apr 12 14:23 : client: [10] command returned 0
Apr 12 14:23 : client: [10] expired
Apr 12 14:23 : client: [10] closed
Apr 12 14:23 : client: [11] opened from 127.0.0.1:65228
Apr 12 14:23 : client: [11] process command "stats"
Apr 12 14:23 : client: [11] command returned 0
Apr 12 14:23 : client: [11] expired
Apr 12 14:23 : client: [11] closed
Apr 12 14:23 : client: [12] opened from 127.0.0.1:65229
Apr 12 14:23 : client: [12] process command "status"
Apr 12 14:23 : client: [12] command returned 0
Apr 12 14:23 : client: [12] expired
Apr 12 14:23 : client: [12] closed
Apr 12 14:23 : client: [13] opened from 127.0.0.1:65230
Apr 12 14:23 : client: [13] process command "stats"
Apr 12 14:23 : client: [13] command returned 0
Apr 12 14:23 : client: [13] expired
Apr 12 14:23 : client: [13] closed
Apr 12 14:25 : client: [14] opened from 127.0.0.1:65236
Apr 12 14:25 : client: [14] process command "listplaylists"
Apr 12 14:25 : client: [14] command returned 0
Apr 12 14:25 : client: [14] expired
Apr 12 14:25 : client: [14] closed
Apr 12 14:28 : client: [15] opened from 127.0.0.1:65383
Apr 12 14:28 : client: [15] process command "listplaylists"
Apr 12 14:28 : client: [15] command returned 0
Apr 12 14:28 : client: [15] expired
Apr 12 14:28 : client: [15] closed
Apr 12 14:29 : client: [16] opened from 127.0.0.1:65385
Apr 12 14:29 : client: [16] process command "listplaylistinfo Playlist One"
Apr 12 14:29 : client: [16] command returned -1
Apr 12 14:29 : client: [16] expired
Apr 12 14:29 : client: [16] closed
Apr 12 14:29 : client: [17] opened from 127.0.0.1:65386
Apr 12 14:29 : client: [17] process command "listplaylistinfo "Playlist One""
Apr 12 14:29 : database: get song: teaspoon-stirring-mug-of-coffee.mp3
Apr 12 14:29 : database: get song: whistle-kettle-boiling.mp3
Apr 12 14:29 : database: get song: wine-glass-double-chink-clink-cheers.mp3
Apr 12 14:29 : database: get song: Directory With Spaces/coin-spin-light.mp3
Apr 12 14:29 : database: get song: Directory With Spaces/finger-snap-click.mp3
Apr 12 14:29 : client: [17] command returned 0
Apr 12 14:29 : client: [17] expired
Apr 12 14:29 : client: [17] closed
Apr 12 14:32 : client: [18] opened from 127.0.0.1:65446
Apr 12 14:32 : client: [18] process command "statstastats"
Apr 12 14:32 : client: [18] command returned -1
Apr 12 14:32 : client: [18] process command "stats"
Apr 12 14:3