mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-01-14 22:18:43 +00:00
Restructured commands
This commit is contained in:
parent
1f59105d4e
commit
393df7ca9a
BIN
Sources/.vs/MpcNET/DesignTimeBuild/.dtbcache
Normal file
BIN
Sources/.vs/MpcNET/DesignTimeBuild/.dtbcache
Normal file
Binary file not shown.
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
1513
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.Test.deps.json
Normal file
1513
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.Test.deps.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.Test.dll
Normal file
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.Test.dll
Normal file
Binary file not shown.
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.Test.pdb
Normal file
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.Test.pdb
Normal file
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"additionalProbingPaths": [
|
||||
"C:\\Users\\kim\\.dotnet\\store\\|arch|\\|tfm|",
|
||||
"C:\\Users\\kim\\.nuget\\packages",
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "netcoreapp2.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.dll
Normal file
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.dll
Normal file
Binary file not shown.
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.pdb
Normal file
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.pdb
Normal file
Binary file not shown.
2176
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.xml
Normal file
2176
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/MpcNET.xml
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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
|
@ -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
|
@ -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
|
@ -0,0 +1 @@
|
||||
mpd.exe mpd.conf -v
|
@ -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"
|
||||
}
|
163
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/Server/mpd.db
Normal file
163
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/Server/mpd.db
Normal 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
|
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/Server/mpd.exe
Normal file
BIN
Sources/MpcNET.Test/bin/Release/netcoreapp2.0/Server/mpd.exe
Normal file
Binary file not shown.
@ -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
|
Binary file not shown.
Binary file not shown.
@ -1,74 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace MpcNET
|
||||
{
|
||||
using MpcNET.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Provides MPD commands.
|
||||
/// </summary>
|
||||
/// <seealso cref="MpcNET.ICommandFactory" />
|
||||
public class CommandFactory : ICommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the status command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The status.
|
||||
/// </value>
|
||||
public IStatusCommandFactory Status { get; } = new StatusCommandFactory();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the database command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The database.
|
||||
/// </value>
|
||||
public IDatabaseCommandFactory Database { get; } = new DatabaseCommandFactory();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reflection command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The reflection.
|
||||
/// </value>
|
||||
public IReflectionCommandFactory Reflection { get; } = new ReflectionCommandFactory();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the stored playlist command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The stored playlist.
|
||||
/// </value>
|
||||
public IStoredPlaylistCommandFactory StoredPlaylist { get; } = new StoredPlaylistCommandFactory();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current playlist command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The current playlist.
|
||||
/// </value>
|
||||
public ICurrentPlaylistCommandFactory CurrentPlaylist { get; } = new CurrentPlaylistCommandFactory();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the playback command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The playback.
|
||||
/// </value>
|
||||
public IPlaybackCommandFactory Playback { get; } = new PlaybackCommandFactory();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the output command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The output.
|
||||
/// </value>
|
||||
public IOutputCommandFactory Output { get; } = new OutputCommandFactory();
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CurrentPlaylistCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Playlist;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.musicpd.org/doc/protocol/queue.html.
|
||||
/// </summary>
|
||||
public class CurrentPlaylistCommandFactory : ICurrentPlaylistCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Command: add.
|
||||
/// </summary>
|
||||
/// <param name="directory">The directory.</param>
|
||||
/// <returns>An <see cref="AddCommand"/>.</returns>
|
||||
public IMpcCommand<string> AddDirectory(string directory)
|
||||
{
|
||||
return new AddCommand(directory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: addid.
|
||||
/// </summary>
|
||||
/// <param name="songPath">The song path.</param>
|
||||
/// <returns>An <see cref="AddIdCommand"/>.</returns>
|
||||
public IMpcCommand<string> AddSong(string songPath)
|
||||
{
|
||||
return new AddIdCommand(songPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: clear.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="ClearCommand"/>.</returns>
|
||||
public IMpcCommand<string> Clear()
|
||||
{
|
||||
return new ClearCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: playlist.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="PlaylistCommand"/>.</returns>
|
||||
public IMpcCommand<IEnumerable<IMpdFile>> GetAllSongsInfo()
|
||||
{
|
||||
return new PlaylistCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: delete.
|
||||
/// </summary>
|
||||
/// <param name="position">The position.</param>
|
||||
/// <returns>A <see cref="DeleteCommand" />.</returns>
|
||||
public IMpcCommand<string> RemoveSongByPosition(int position)
|
||||
{
|
||||
return new DeleteCommand(position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: deleteid.
|
||||
/// </summary>
|
||||
/// <param name="songId">The song identifier.</param>
|
||||
/// <returns>A <see cref="DeleteIdCommand"/>.</returns>
|
||||
public IMpcCommand<string> RemoveSongById(int songId)
|
||||
{
|
||||
return new DeleteIdCommand(songId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: playlistid.
|
||||
/// </summary>
|
||||
/// <param name="songId">The song identifier.</param>
|
||||
/// <returns>A <see cref="PlaylistIdCommand" />.</returns>
|
||||
public IMpcCommand<IEnumerable<IMpdFile>> GetSongMetadata(int songId)
|
||||
{
|
||||
return new PlaylistIdCommand(songId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: playlistinfo.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="PlaylistInfoCommand" />.</returns>
|
||||
public IMpcCommand<IEnumerable<IMpdFile>> GetAllSongMetadata()
|
||||
{
|
||||
return new PlaylistInfoCommand();
|
||||
}
|
||||
}
|
||||
}
|
@ -12,20 +12,39 @@ namespace MpcNET.Commands.Database
|
||||
|
||||
/// <summary>
|
||||
/// Finds songs in the database that is exactly "searchText".
|
||||
/// https://www.musicpd.org/doc/protocol/database.html.
|
||||
/// </summary>
|
||||
internal class FindCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
public class FindCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
{
|
||||
private readonly ITag tag;
|
||||
private readonly string searchText;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FindCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="tag">The tag.</param>
|
||||
/// <param name="searchText">The search text.</param>
|
||||
public FindCommand(ITag tag, string searchText)
|
||||
{
|
||||
this.tag = tag;
|
||||
this.searchText = searchText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "find", this.tag.Value, this.searchText);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<IMpdFile> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return MpdFile.CreateList(response);
|
||||
|
@ -12,11 +12,25 @@ namespace MpcNET.Commands.Database
|
||||
|
||||
/// <summary>
|
||||
/// Lists all songs and directories in URI.
|
||||
/// https://www.musicpd.org/doc/protocol/database.html.
|
||||
/// </summary>
|
||||
internal class ListAllCommand : IMpcCommand<IEnumerable<MpdDirectory>>
|
||||
public class ListAllCommand : IMpcCommand<IEnumerable<MpdDirectory>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "listall";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<MpdDirectory> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
var rootDirectory = new List<MpdDirectory>
|
||||
|
@ -9,17 +9,38 @@ namespace MpcNET.Commands.Database
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Tags;
|
||||
|
||||
internal class ListCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Lists the specified tag.
|
||||
/// https://www.musicpd.org/doc/protocol/database.html.
|
||||
/// </summary>
|
||||
public class ListCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly ITag tag;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="tag">The tag.</param>
|
||||
public ListCommand(ITag tag)
|
||||
{
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "list", this.tag);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
// TODO:
|
||||
|
@ -8,15 +8,37 @@ namespace MpcNET.Commands.Database
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class UpdateCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Updates the specified URI.
|
||||
/// https://www.musicpd.org/doc/protocol/database.html.
|
||||
/// </summary>
|
||||
public class UpdateCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly string uri;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateCommand"/> class.
|
||||
/// </summary>
|
||||
public UpdateCommand()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="uri">The URI.</param>
|
||||
public UpdateCommand(string uri)
|
||||
{
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.uri))
|
||||
@ -38,6 +60,13 @@ namespace MpcNET.Commands.Database
|
||||
return string.Join(" ", "update", newUri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -1,52 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="DatabaseCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Database;
|
||||
using MpcNET.Tags;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.musicpd.org/doc/protocol/database.html.
|
||||
/// </summary>
|
||||
public class DatabaseCommandFactory : IDatabaseCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Finds the specified tag.
|
||||
/// </summary>
|
||||
/// <param name="tag">The tag.</param>
|
||||
/// <param name="searchText">The search text.</param>
|
||||
/// <returns>An <see cref="FindCommand"/>.</returns>
|
||||
public IMpcCommand<IEnumerable<IMpdFile>> Find(ITag tag, string searchText)
|
||||
{
|
||||
return new FindCommand(tag, searchText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the specified URI.
|
||||
/// </summary>
|
||||
/// <param name="uri">The URI.</param>
|
||||
/// <returns>An <see cref="UpdateCommand"/>.</returns>
|
||||
public IMpcCommand<string> Update(string uri = null)
|
||||
{
|
||||
return new UpdateCommand(uri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists all.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="ListAllCommand"/>.</returns>
|
||||
public IMpcCommand<IEnumerable<MpdDirectory>> ListAll()
|
||||
{
|
||||
return new ListAllCommand();
|
||||
}
|
||||
|
||||
// TODO: count
|
||||
// TODO: rescan
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="ICurrentPlaylistCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Playlist;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Provides current playlist commands.
|
||||
/// </summary>
|
||||
public interface ICurrentPlaylistCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Command: add.
|
||||
/// </summary>
|
||||
/// <param name="directory">The directory.</param>
|
||||
/// <returns>An <see cref="AddCommand"/>.</returns>
|
||||
IMpcCommand<string> AddDirectory(string directory);
|
||||
|
||||
/// <summary>
|
||||
/// Command: addid.
|
||||
/// </summary>
|
||||
/// <param name="songPath">The song path.</param>
|
||||
/// <returns>An <see cref="AddIdCommand"/>.</returns>
|
||||
IMpcCommand<string> AddSong(string songPath);
|
||||
|
||||
/// <summary>
|
||||
/// Command: clear.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="ClearCommand"/>.</returns>
|
||||
IMpcCommand<string> Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Command: playlist.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="PlaylistCommand"/>.</returns>
|
||||
IMpcCommand<IEnumerable<IMpdFile>> GetAllSongsInfo();
|
||||
|
||||
/// <summary>
|
||||
/// Command: delete.
|
||||
/// </summary>
|
||||
/// <param name="position">The position.</param>
|
||||
/// <returns>A <see cref="DeleteCommand" />.</returns>
|
||||
IMpcCommand<string> RemoveSongByPosition(int position);
|
||||
|
||||
/// <summary>
|
||||
/// Command: deleteid.
|
||||
/// </summary>
|
||||
/// <param name="songId">The song identifier.</param>
|
||||
/// <returns>A <see cref="DeleteIdCommand"/>.</returns>
|
||||
IMpcCommand<string> RemoveSongById(int songId);
|
||||
|
||||
/// <summary>
|
||||
/// Command: playlistid.
|
||||
/// </summary>
|
||||
/// <param name="songId">The song identifier.</param>
|
||||
/// <returns>A <see cref="PlaylistIdCommand" />.</returns>
|
||||
IMpcCommand<IEnumerable<IMpdFile>> GetSongMetadata(int songId);
|
||||
|
||||
/// <summary>
|
||||
/// Command: playlistinfo.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="PlaylistInfoCommand" />.</returns>
|
||||
IMpcCommand<IEnumerable<IMpdFile>> GetAllSongMetadata();
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="IDatabaseCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Database;
|
||||
using MpcNET.Tags;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Provides database commands.
|
||||
/// </summary>
|
||||
public interface IDatabaseCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Finds the specified tag.
|
||||
/// </summary>
|
||||
/// <param name="tag">The tag.</param>
|
||||
/// <param name="searchText">The search text.</param>
|
||||
/// <returns>An <see cref="FindCommand"/>.</returns>
|
||||
IMpcCommand<IEnumerable<IMpdFile>> Find(ITag tag, string searchText);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the specified URI.
|
||||
/// </summary>
|
||||
/// <param name="uri">The URI.</param>
|
||||
/// <returns>An <see cref="UpdateCommand"/>.</returns>
|
||||
IMpcCommand<string> Update(string uri = null);
|
||||
|
||||
/// <summary>
|
||||
/// Lists all.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="ListAllCommand"/>.</returns>
|
||||
IMpcCommand<IEnumerable<MpdDirectory>> ListAll();
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="IOutputCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Output;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Provides output commands.
|
||||
/// </summary>
|
||||
public interface IOutputCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Outputses this instance.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="OutputsCommand"/>.</returns>
|
||||
IMpcCommand<IEnumerable<MpdOutput>> Outputs();
|
||||
|
||||
/// <summary>
|
||||
/// Disables the output.
|
||||
/// </summary>
|
||||
/// <param name="outputId">The output identifier.</param>
|
||||
/// <returns>A <see cref="DisableOutputCommand"/>.</returns>
|
||||
IMpcCommand<string> DisableOutput(int outputId);
|
||||
|
||||
/// <summary>
|
||||
/// Enables the output.
|
||||
/// </summary>
|
||||
/// <param name="outputId">The output identifier.</param>
|
||||
/// <returns>A <see cref="EnableOutputCommand"/>.</returns>
|
||||
IMpcCommand<string> EnableOutput(int outputId);
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the output.
|
||||
/// </summary>
|
||||
/// <param name="outputId">The output identifier.</param>
|
||||
/// <returns>A <see cref="ToggleOutputCommand"/>.</returns>
|
||||
IMpcCommand<string> ToggleOutput(int outputId);
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="IPlaybackCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using MpcNET.Commands.Playback;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Provides playback commands.
|
||||
/// </summary>
|
||||
public interface IPlaybackCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a next command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="NextCommand"/>.</returns>
|
||||
IMpcCommand<string> Next();
|
||||
|
||||
/// <summary>
|
||||
/// Get a previous command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="StopCommand"/>.</returns>
|
||||
IMpcCommand<string> Previous();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a play-pause command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="PlayPauseCommand"/>.</returns>
|
||||
IMpcCommand<string> PlayPause();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a play command.
|
||||
/// </summary>
|
||||
/// <param name="mpdFile">The MPD file.</param>
|
||||
/// <returns>A <see cref="PlayCommand"/>.</returns>
|
||||
IMpcCommand<string> Play(IMpdFile mpdFile);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a play command.
|
||||
/// </summary>
|
||||
/// <param name="position">The position.</param>
|
||||
/// <returns>A <see cref="PlayCommand"/>.</returns>
|
||||
IMpcCommand<string> Play(int position);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a play command.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <returns>A <see cref="PlayCommand"/>.</returns>
|
||||
IMpcCommand<string> PlayId(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stop command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="StopCommand"/>.</returns>
|
||||
IMpcCommand<string> Stop();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the volume.
|
||||
/// </summary>
|
||||
/// <param name="volume">The volume.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="SetVolumeCommand" />.
|
||||
/// </returns>
|
||||
IMpcCommand<string> SetVolume(byte volume);
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="IReflectionCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Reflection;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Provides reflection commands.
|
||||
/// </summary>
|
||||
public interface IReflectionCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a commands command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="CommandsCommand"/>.</returns>
|
||||
IMpcCommand<IEnumerable<string>> Commands();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a tag types command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="TagTypesCommand"/>.</returns>
|
||||
IMpcCommand<IEnumerable<string>> TagTypes();
|
||||
|
||||
/// <summary>
|
||||
/// Gets URL handlers command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="UrlHandlersCommand"/>.</returns>
|
||||
IMpcCommand<IEnumerable<string>> UrlHandlers();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a decoders command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="DecodersCommand"/>.</returns>
|
||||
IMpcCommand<IEnumerable<MpdDecoderPlugin>> Decoders();
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="IStatusCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using MpcNET.Commands.Status;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Provides status commands.
|
||||
/// </summary>
|
||||
public interface IStatusCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a status command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="StatusCommand"/>.</returns>
|
||||
IMpcCommand<MpdStatus> GetStatus();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a current song command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="CurrentSongCommand"/>.</returns>
|
||||
IMpcCommand<IMpdFile> GetCurrentSong();
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="IStoredPlaylistCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Playlist;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Provides stored playlist commands.
|
||||
/// </summary>
|
||||
public interface IStoredPlaylistCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Command: load.
|
||||
/// </summary>
|
||||
/// <param name="playlistName">Name of the playlist.</param>
|
||||
/// <returns>A <see cref="LoadCommand" />.</returns>
|
||||
IMpcCommand<string> Load(string playlistName);
|
||||
|
||||
/// <summary>
|
||||
/// Command: listplaylist.
|
||||
/// </summary>
|
||||
/// <param name="playlistName">Name of the playlist.</param>
|
||||
/// <returns>A <see cref="ListPlaylistCommand" />.</returns>
|
||||
IMpcCommand<IEnumerable<IMpdFilePath>> GetContent(string playlistName);
|
||||
|
||||
/// <summary>
|
||||
/// Command: listplaylistinfo.
|
||||
/// </summary>
|
||||
/// <param name="playlistName">Name of the playlist.</param>
|
||||
/// <returns>A <see cref="ListPlaylistInfoCommand" />.</returns>
|
||||
IMpcCommand<IEnumerable<IMpdFile>> GetContentWithMetadata(string playlistName);
|
||||
|
||||
/// <summary>
|
||||
/// Command: listplaylists.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="ListPlaylistsCommand" />.</returns>
|
||||
IMpcCommand<IEnumerable<MpdPlaylist>> GetAll();
|
||||
}
|
||||
}
|
@ -10,18 +10,36 @@ namespace MpcNET.Commands.Output
|
||||
|
||||
/// <summary>
|
||||
/// Turns an output off.
|
||||
/// https://www.musicpd.org/doc/protocol/output_commands.html.
|
||||
/// </summary>
|
||||
internal class DisableOutputCommand : IMpcCommand<string>
|
||||
public class DisableOutputCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly int outputId;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DisableOutputCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="outputId">The output identifier.</param>
|
||||
public DisableOutputCommand(int outputId)
|
||||
{
|
||||
this.outputId = outputId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "disableoutput", this.outputId);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
// Response should be empty.
|
||||
|
@ -10,18 +10,36 @@ namespace MpcNET.Commands.Output
|
||||
|
||||
/// <summary>
|
||||
/// Turns an output on.
|
||||
/// https://www.musicpd.org/doc/protocol/output_commands.html.
|
||||
/// </summary>
|
||||
internal class EnableOutputCommand : IMpcCommand<string>
|
||||
public class EnableOutputCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly int outputId;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EnableOutputCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="outputId">The output identifier.</param>
|
||||
public EnableOutputCommand(int outputId)
|
||||
{
|
||||
this.outputId = outputId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "enableoutput", this.outputId);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
// Response should be empty.
|
||||
|
@ -11,11 +11,25 @@ namespace MpcNET.Commands.Output
|
||||
|
||||
/// <summary>
|
||||
/// Shows information about all outputs.
|
||||
/// https://www.musicpd.org/doc/protocol/output_commands.html.
|
||||
/// </summary>
|
||||
internal class OutputsCommand : IMpcCommand<IEnumerable<MpdOutput>>
|
||||
public class OutputsCommand : IMpcCommand<IEnumerable<MpdOutput>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "outputs";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<MpdOutput> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
var result = new List<MpdOutput>();
|
||||
|
@ -10,18 +10,36 @@ namespace MpcNET.Commands.Output
|
||||
|
||||
/// <summary>
|
||||
/// Turns an output on or off, depending on the current state.
|
||||
/// https://www.musicpd.org/doc/protocol/output_commands.html.
|
||||
/// </summary>
|
||||
internal class ToggleOutputCommand : IMpcCommand<string>
|
||||
public class ToggleOutputCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly int outputId;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ToggleOutputCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="outputId">The output identifier.</param>
|
||||
public ToggleOutputCommand(int outputId)
|
||||
{
|
||||
this.outputId = outputId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "toggleoutput", this.outputId);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -1,57 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="OutputCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Output;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.musicpd.org/doc/protocol/output_commands.html.
|
||||
/// </summary>
|
||||
public class OutputCommandFactory : IOutputCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Outputses this instance.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="OutputsCommand"/>.</returns>
|
||||
public IMpcCommand<IEnumerable<MpdOutput>> Outputs()
|
||||
{
|
||||
return new OutputsCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables the output.
|
||||
/// </summary>
|
||||
/// <param name="outputId">The output identifier.</param>
|
||||
/// <returns>A <see cref="DisableOutputCommand"/>.</returns>
|
||||
public IMpcCommand<string> DisableOutput(int outputId)
|
||||
{
|
||||
return new DisableOutputCommand(outputId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the output.
|
||||
/// </summary>
|
||||
/// <param name="outputId">The output identifier.</param>
|
||||
/// <returns>A <see cref="EnableOutputCommand"/>.</returns>
|
||||
public IMpcCommand<string> EnableOutput(int outputId)
|
||||
{
|
||||
return new EnableOutputCommand(outputId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the output.
|
||||
/// </summary>
|
||||
/// <param name="outputId">The output identifier.</param>
|
||||
/// <returns>A <see cref="ToggleOutputCommand"/>.</returns>
|
||||
public IMpcCommand<string> ToggleOutput(int outputId)
|
||||
{
|
||||
return new ToggleOutputCommand(outputId);
|
||||
}
|
||||
}
|
||||
}
|
@ -8,10 +8,27 @@ namespace MpcNET.Commands.Playback
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class NextCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Command to go to next song.
|
||||
/// https://www.musicpd.org/doc/protocol/playback_commands.html.
|
||||
/// </summary>
|
||||
public class NextCommand : IMpcCommand<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "next");
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -10,31 +10,45 @@ namespace MpcNET.Commands.Playback
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Types;
|
||||
|
||||
internal class PlayCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Command to start playback.
|
||||
/// https://www.musicpd.org/doc/protocol/playback_commands.html.
|
||||
/// </summary>
|
||||
public class PlayCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly int position;
|
||||
private readonly int id;
|
||||
|
||||
public PlayCommand(int position, int id)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlayCommand" /> class.
|
||||
/// </summary>
|
||||
/// <param name="position">The position.</param>
|
||||
public PlayCommand(int position)
|
||||
{
|
||||
this.position = position;
|
||||
this.id = id;
|
||||
if (this.position == MpdFile.NoPos && this.id == MpdFile.NoId)
|
||||
if (this.position == MpdFile.NoPos)
|
||||
{
|
||||
throw new ArgumentException("PlayCommand requires Id or Position");
|
||||
throw new ArgumentException("PlayCommand requires Position");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize()
|
||||
{
|
||||
if (this.id != MpdFile.NoId)
|
||||
{
|
||||
return string.Join(" ", "playid", this.id);
|
||||
}
|
||||
|
||||
return string.Join(" ", "play", this.position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
57
Sources/MpcNET/Commands/Playback/PlayIdCommand.cs
Normal file
57
Sources/MpcNET/Commands/Playback/PlayIdCommand.cs
Normal file
@ -0,0 +1,57 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="PlayIdCommand.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands.Playback
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Command to start playback.
|
||||
/// https://www.musicpd.org/doc/protocol/playback_commands.html.
|
||||
/// </summary>
|
||||
public class PlayIdCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly int id;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlayIdCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
public PlayIdCommand(int id)
|
||||
{
|
||||
this.id = id;
|
||||
if (this.id == MpdFile.NoId)
|
||||
{
|
||||
throw new ArgumentException("PlayIdCommand requires Id");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize()
|
||||
{
|
||||
return string.Join(" ", "playid", this.id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
}
|
||||
}
|
||||
}
|
@ -8,10 +8,27 @@ namespace MpcNET.Commands.Playback
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class PlayPauseCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Command to play or pause.
|
||||
/// https://www.musicpd.org/doc/protocol/playback_commands.html.
|
||||
/// </summary>
|
||||
public class PlayPauseCommand : IMpcCommand<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "pause");
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -8,10 +8,27 @@ namespace MpcNET.Commands.Playback
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class PreviousCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Command to goto previous song.
|
||||
/// https://www.musicpd.org/doc/protocol/playback_commands.html.
|
||||
/// </summary>
|
||||
public class PreviousCommand : IMpcCommand<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "previous");
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -9,20 +9,41 @@ namespace MpcNET.Commands.Playback
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class SetVolumeCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Command to set volume.
|
||||
/// https://www.musicpd.org/doc/protocol/playback_commands.html.
|
||||
/// </summary>
|
||||
public class SetVolumeCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly byte volume;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetVolumeCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="volume">The volume.</param>
|
||||
public SetVolumeCommand(byte volume)
|
||||
{
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize()
|
||||
{
|
||||
return string.Join(" ", "setvol", this.volume);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -8,10 +8,27 @@ namespace MpcNET.Commands.Playback
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class StopCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Command to stop playback.
|
||||
/// https://www.musicpd.org/doc/protocol/playback_commands.html.
|
||||
/// </summary>
|
||||
public class StopCommand : IMpcCommand<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "stop");
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -1,95 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="PlaybackCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using MpcNET.Commands.Playback;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.musicpd.org/doc/protocol/playback_commands.html.
|
||||
/// </summary>
|
||||
public class PlaybackCommandFactory : IPlaybackCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a next command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="NextCommand"/>.</returns>
|
||||
public IMpcCommand<string> Next()
|
||||
{
|
||||
return new NextCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a previous command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="StopCommand"/>.</returns>
|
||||
public IMpcCommand<string> Previous()
|
||||
{
|
||||
return new PreviousCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a play-pause command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="PlayPauseCommand"/>.</returns>
|
||||
public IMpcCommand<string> PlayPause()
|
||||
{
|
||||
return new PlayPauseCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a play command.
|
||||
/// </summary>
|
||||
/// <param name="mpdFile">The MPD file.</param>
|
||||
/// <returns>A <see cref="PlayCommand"/>.</returns>
|
||||
public IMpcCommand<string> Play(IMpdFile mpdFile)
|
||||
{
|
||||
return new PlayCommand(mpdFile.Id, mpdFile.Position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a play command.
|
||||
/// </summary>
|
||||
/// <param name="position">The position.</param>
|
||||
/// <returns>A <see cref="PlayCommand"/>.</returns>
|
||||
public IMpcCommand<string> Play(int position)
|
||||
{
|
||||
return new PlayCommand(position, MpdFile.NoId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a play command.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <returns>A <see cref="PlayCommand"/>.</returns>
|
||||
public IMpcCommand<string> PlayId(int id)
|
||||
{
|
||||
return new PlayCommand(MpdFile.NoPos, id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stop command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="StopCommand"/>.</returns>
|
||||
public IMpcCommand<string> Stop()
|
||||
{
|
||||
return new StopCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the volume.
|
||||
/// </summary>
|
||||
/// <param name="volume">The volume.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:MpcNET.Commands.Playback.SetVolumeCommand" />.
|
||||
/// </returns>
|
||||
public IMpcCommand<string> SetVolume(byte volume)
|
||||
{
|
||||
return new SetVolumeCommand(volume);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,18 +10,36 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Adds the file URI to the playlist (directories add recursively). URI can also be a single file.
|
||||
/// https://www.musicpd.org/doc/protocol/queue.html.
|
||||
/// </summary>
|
||||
internal class AddCommand : IMpcCommand<string>
|
||||
public class AddCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly string uri;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="uri">The URI.</param>
|
||||
public AddCommand(string uri)
|
||||
{
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "add", $"\"{this.uri}\"");
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -10,18 +10,36 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Adds a song to the playlist (non-recursive) and returns the song id.
|
||||
/// https://www.musicpd.org/doc/protocol/queue.html.
|
||||
/// </summary>
|
||||
internal class AddIdCommand : IMpcCommand<string>
|
||||
public class AddIdCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly string uri;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddIdCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="uri">The URI.</param>
|
||||
public AddIdCommand(string uri)
|
||||
{
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "addid", $"\"{this.uri}\"");
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -10,11 +10,25 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Clears the current playlist.
|
||||
/// https://www.musicpd.org/doc/protocol/queue.html.
|
||||
/// </summary>
|
||||
internal class ClearCommand : IMpcCommand<string>
|
||||
public class ClearCommand : IMpcCommand<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "clear";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -10,18 +10,36 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a song from the playlist.
|
||||
/// https://www.musicpd.org/doc/protocol/queue.html.
|
||||
/// </summary>
|
||||
internal class DeleteCommand : IMpcCommand<string>
|
||||
public class DeleteCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly int position;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeleteCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="position">The position.</param>
|
||||
public DeleteCommand(int position)
|
||||
{
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "delete", this.position);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -10,18 +10,36 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the song SONGID from the playlist.
|
||||
/// https://www.musicpd.org/doc/protocol/queue.html.
|
||||
/// </summary>
|
||||
internal class DeleteIdCommand : IMpcCommand<string>
|
||||
public class DeleteIdCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly int songId;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeleteIdCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="songId">The song identifier.</param>
|
||||
public DeleteIdCommand(int songId)
|
||||
{
|
||||
this.songId = songId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "deleteid", this.songId);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -12,18 +12,36 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Lists the songs in the playlist.
|
||||
/// https://www.musicpd.org/doc/protocol/playlist_files.html.
|
||||
/// </summary>
|
||||
internal class ListPlaylistCommand : IMpcCommand<IEnumerable<IMpdFilePath>>
|
||||
public class ListPlaylistCommand : IMpcCommand<IEnumerable<IMpdFilePath>>
|
||||
{
|
||||
private readonly string playlistName;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListPlaylistCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="playlistName">Name of the playlist.</param>
|
||||
public ListPlaylistCommand(string playlistName)
|
||||
{
|
||||
this.playlistName = playlistName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "listplaylist", $"\"{this.playlistName}\"");
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<IMpdFilePath> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
var results = response.Where(line => line.Key.Equals("file")).Select(line => new MpdFile(line.Value));
|
||||
|
@ -11,18 +11,36 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Lists the songs with metadata in the playlist.
|
||||
/// https://www.musicpd.org/doc/protocol/playlist_files.html.
|
||||
/// </summary>
|
||||
internal class ListPlaylistInfoCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
public class ListPlaylistInfoCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
{
|
||||
private readonly string playlistName;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ListPlaylistInfoCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="playlistName">Name of the playlist.</param>
|
||||
public ListPlaylistInfoCommand(string playlistName)
|
||||
{
|
||||
this.playlistName = playlistName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "listplaylistinfo", $"\"{this.playlistName}\"");
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<IMpdFile> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return MpdFile.CreateList(response);
|
||||
|
@ -12,11 +12,25 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Prints a list of the playlist directory.
|
||||
/// https://www.musicpd.org/doc/protocol/playlist_files.html.
|
||||
/// </summary>
|
||||
internal class ListPlaylistsCommand : IMpcCommand<IEnumerable<MpdPlaylist>>
|
||||
public class ListPlaylistsCommand : IMpcCommand<IEnumerable<MpdPlaylist>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "listplaylists";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<MpdPlaylist> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
var result = new List<MpdPlaylist>();
|
||||
|
@ -10,18 +10,36 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Loads the playlist into the current queue.
|
||||
/// https://www.musicpd.org/doc/protocol/playlist_files.html.
|
||||
/// </summary>
|
||||
internal class LoadCommand : IMpcCommand<string>
|
||||
public class LoadCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly string playlistName;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LoadCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="playlistName">Name of the playlist.</param>
|
||||
public LoadCommand(string playlistName)
|
||||
{
|
||||
this.playlistName = playlistName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", "load", $"\"{this.playlistName}\"");
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -12,11 +12,25 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Displays the current playlist.
|
||||
/// https://www.musicpd.org/doc/protocol/queue.html.
|
||||
/// </summary>
|
||||
internal class PlaylistCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
public class PlaylistCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "playlist";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<IMpdFile> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
var results = response.Select(line => MpdFile.Create(line.Value, int.Parse(line.Key)));
|
||||
|
@ -11,18 +11,36 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Displays song ID in the playlist.
|
||||
/// https://www.musicpd.org/doc/protocol/queue.html.
|
||||
/// </summary>
|
||||
internal class PlaylistIdCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
public class PlaylistIdCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
{
|
||||
private readonly int songId;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlaylistIdCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="songId">The song identifier.</param>
|
||||
public PlaylistIdCommand(int songId)
|
||||
{
|
||||
this.songId = songId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => string.Join(" ", new[] { "playlistid" }, this.songId);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<IMpdFile> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return MpdFile.CreateList(response);
|
||||
|
@ -11,11 +11,25 @@ namespace MpcNET.Commands.Playlist
|
||||
|
||||
/// <summary>
|
||||
/// Displays a list of all songs in the playlist.
|
||||
/// https://www.musicpd.org/doc/protocol/queue.html.
|
||||
/// </summary>
|
||||
internal class PlaylistInfoCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
public class PlaylistInfoCommand : IMpcCommand<IEnumerable<IMpdFile>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "playlistinfo";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<IMpdFile> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return MpdFile.CreateList(response);
|
||||
|
@ -12,11 +12,25 @@ namespace MpcNET.Commands.Reflection
|
||||
/// <summary>
|
||||
/// Shows which commands the current user has access to.
|
||||
/// config : This command is only permitted to "local" clients (connected via UNIX domain socket).
|
||||
/// https://www.musicpd.org/doc/protocol/reflection_commands.html.
|
||||
/// </summary>
|
||||
internal class CommandsCommand : IMpcCommand<IEnumerable<string>>
|
||||
public class CommandsCommand : IMpcCommand<IEnumerable<string>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "commands";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<string> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
var result = response.Where(item => item.Key.Equals("command")).Select(item => item.Value);
|
||||
|
@ -11,11 +11,25 @@ namespace MpcNET.Commands.Reflection
|
||||
|
||||
/// <summary>
|
||||
/// Print a list of decoder plugins, followed by their supported suffixes and MIME types.
|
||||
/// https://www.musicpd.org/doc/protocol/reflection_commands.html.
|
||||
/// </summary>
|
||||
internal class DecodersCommand : IMpcCommand<IEnumerable<MpdDecoderPlugin>>
|
||||
public class DecodersCommand : IMpcCommand<IEnumerable<MpdDecoderPlugin>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "decoders";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<MpdDecoderPlugin> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
var result = new List<MpdDecoderPlugin>();
|
||||
|
@ -13,11 +13,25 @@ namespace MpcNET.Commands.Reflection
|
||||
|
||||
/// <summary>
|
||||
/// Shows a list of available song metadata.
|
||||
/// https://www.musicpd.org/doc/protocol/reflection_commands.html.
|
||||
/// </summary>
|
||||
internal class TagTypesCommand : IMpcCommand<IEnumerable<string>>
|
||||
public class TagTypesCommand : IMpcCommand<IEnumerable<string>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "tagtypes";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<string> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
var result = response.Where(item => item.Key.Equals("tagtype")).Select(item => item.Value);
|
||||
|
@ -11,11 +11,25 @@ namespace MpcNET.Commands.Reflection
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of available URL handlers.
|
||||
/// https://www.musicpd.org/doc/protocol/reflection_commands.html.
|
||||
/// </summary>
|
||||
internal class UrlHandlersCommand : IMpcCommand<IEnumerable<string>>
|
||||
public class UrlHandlersCommand : IMpcCommand<IEnumerable<string>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "urlhandlers";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IEnumerable<string> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
var result = response.Where(item => item.Key.Equals("handler")).Select(item => item.Value);
|
||||
|
@ -1,54 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="ReflectionCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Reflection;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.musicpd.org/doc/protocol/reflection_commands.html.
|
||||
/// </summary>
|
||||
public class ReflectionCommandFactory : IReflectionCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a commands command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="CommandsCommand"/>.</returns>
|
||||
public IMpcCommand<IEnumerable<string>> Commands()
|
||||
{
|
||||
return new CommandsCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a tag types command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="TagTypesCommand"/>.</returns>
|
||||
public IMpcCommand<IEnumerable<string>> TagTypes()
|
||||
{
|
||||
return new TagTypesCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets URL handlers command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="UrlHandlersCommand"/>.</returns>
|
||||
public IMpcCommand<IEnumerable<string>> UrlHandlers()
|
||||
{
|
||||
return new UrlHandlersCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a decoders command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="DecodersCommand"/>.</returns>
|
||||
public IMpcCommand<IEnumerable<MpdDecoderPlugin>> Decoders()
|
||||
{
|
||||
return new DecodersCommand();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,10 +9,27 @@ namespace MpcNET.Commands.Status
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Types;
|
||||
|
||||
internal class CurrentSongCommand : IMpcCommand<IMpdFile>
|
||||
/// <summary>
|
||||
/// Gets the current song.
|
||||
/// https://www.musicpd.org/doc/protocol/command_reference.html#status_commands.
|
||||
/// </summary>
|
||||
public class CurrentSongCommand : IMpcCommand<IMpdFile>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "currentsong";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public IMpdFile Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return MpdFile.Create(response, 0).mpdFile;
|
||||
|
@ -8,15 +8,29 @@ namespace MpcNET.Commands.Status
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class IdleCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Idles mpd until something happens.
|
||||
/// https://www.musicpd.org/doc/protocol/command_reference.html#status_commands.
|
||||
/// </summary>
|
||||
public class IdleCommand : IMpcCommand<string>
|
||||
{
|
||||
private readonly string subSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IdleCommand"/> class.
|
||||
/// </summary>
|
||||
/// <param name="subSystem">The sub system.</param>
|
||||
public IdleCommand(string subSystem)
|
||||
{
|
||||
this.subSystem = subSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.subSystem))
|
||||
@ -27,6 +41,13 @@ namespace MpcNET.Commands.Status
|
||||
return "idle " + this.subSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -8,10 +8,27 @@ namespace MpcNET.Commands.Status
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class NoIdleCommand : IMpcCommand<string>
|
||||
/// <summary>
|
||||
/// Cancels idle command.
|
||||
/// https://www.musicpd.org/doc/protocol/command_reference.html#status_commands.
|
||||
/// </summary>
|
||||
public class NoIdleCommand : IMpcCommand<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "noidle";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
return string.Join(", ", response);
|
||||
|
@ -10,7 +10,11 @@ namespace MpcNET.Commands.Status
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
internal class StatusCommand : IMpcCommand<MpdStatus>
|
||||
/// <summary>
|
||||
/// Gets the status.
|
||||
/// https://www.musicpd.org/doc/protocol/command_reference.html#status_commands.
|
||||
/// </summary>
|
||||
public class StatusCommand : IMpcCommand<MpdStatus>
|
||||
{
|
||||
private const string VolumeText = "volume";
|
||||
private const string RepeatText = "repeat";
|
||||
@ -33,8 +37,21 @@ namespace MpcNET.Commands.Status
|
||||
private const string MixrampDbText = "mixrampdb";
|
||||
private const string UpdatingDbText = "updating_db";
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the command.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The serialize command.
|
||||
/// </returns>
|
||||
public string Serialize() => "status";
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the specified response text pairs.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>
|
||||
/// The deserialized response.
|
||||
/// </returns>
|
||||
public MpdStatus Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
|
||||
{
|
||||
int volume = -1;
|
||||
|
@ -1,35 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="StatusCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using MpcNET.Commands.Status;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.musicpd.org/doc/protocol/command_reference.html#status_commands.
|
||||
/// </summary>
|
||||
public class StatusCommandFactory : IStatusCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a status command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="StatusCommand"/>.</returns>
|
||||
public IMpcCommand<MpdStatus> GetStatus()
|
||||
{
|
||||
return new StatusCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a current song command.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="CurrentSongCommand"/>.</returns>
|
||||
public IMpcCommand<IMpdFile> GetCurrentSong()
|
||||
{
|
||||
return new CurrentSongCommand();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="StoredPlaylistCommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET.Commands
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using MpcNET.Commands.Playlist;
|
||||
using MpcNET.Types;
|
||||
|
||||
/// <summary>
|
||||
/// https://www.musicpd.org/doc/protocol/playlist_files.html.
|
||||
/// </summary>
|
||||
public class StoredPlaylistCommandFactory : IStoredPlaylistCommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Command: load.
|
||||
/// </summary>
|
||||
/// <param name="playlistName">Name of the playlist.</param>
|
||||
/// <returns>A <see cref="LoadCommand" />.</returns>
|
||||
public IMpcCommand<string> Load(string playlistName)
|
||||
{
|
||||
return new LoadCommand(playlistName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: listplaylist.
|
||||
/// </summary>
|
||||
/// <param name="playlistName">Name of the playlist.</param>
|
||||
/// <returns>A <see cref="ListPlaylistCommand" />.</returns>
|
||||
public IMpcCommand<IEnumerable<IMpdFilePath>> GetContent(string playlistName)
|
||||
{
|
||||
return new ListPlaylistCommand(playlistName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: listplaylistinfo.
|
||||
/// </summary>
|
||||
/// <param name="playlistName">Name of the playlist.</param>
|
||||
/// <returns>A <see cref="ListPlaylistInfoCommand" />.</returns>
|
||||
public IMpcCommand<IEnumerable<IMpdFile>> GetContentWithMetadata(string playlistName)
|
||||
{
|
||||
return new ListPlaylistInfoCommand(playlistName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command: listplaylists.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="ListPlaylistsCommand" />.</returns>
|
||||
public IMpcCommand<IEnumerable<MpdPlaylist>> GetAll()
|
||||
{
|
||||
return new ListPlaylistsCommand();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="ICommandFactory.cs" company="MpcNET">
|
||||
// Copyright (c) MpcNET. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace MpcNET
|
||||
{
|
||||
using MpcNET.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for providing specific command factories.
|
||||
/// </summary>
|
||||
public interface ICommandFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the status command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The status.
|
||||
/// </value>
|
||||
IStatusCommandFactory Status { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the database command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The database.
|
||||
/// </value>
|
||||
IDatabaseCommandFactory Database { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reflection command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The reflection.
|
||||
/// </value>
|
||||
IReflectionCommandFactory Reflection { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the stored playlist command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The stored playlist.
|
||||
/// </value>
|
||||
IStoredPlaylistCommandFactory StoredPlaylist { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current playlist command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The current playlist.
|
||||
/// </value>
|
||||
ICurrentPlaylistCommandFactory CurrentPlaylist { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the playback command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The playback.
|
||||
/// </value>
|
||||
IPlaybackCommandFactory Playback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the output command factory.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The output.
|
||||
/// </value>
|
||||
IOutputCommandFactory Output { get; }
|
||||
}
|
||||
}
|
@ -38,8 +38,10 @@ namespace MpcNET
|
||||
/// Sends the command asynchronously.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse">The response type.</typeparam>
|
||||
/// <param name="commandSelector">The command selector.</param>
|
||||
/// <returns>The send task.</returns>
|
||||
Task<IMpdMessage<TResponse>> SendAsync<TResponse>(Func<ICommandFactory, IMpcCommand<TResponse>> commandSelector);
|
||||
/// <param name="mpcCommand">The command selector.</param>
|
||||
/// <returns>
|
||||
/// The send task.
|
||||
/// </returns>
|
||||
Task<IMpdMessage<TResponse>> SendAsync<TResponse>(IMpcCommand<TResponse> mpcCommand);
|
||||
}
|
||||
}
|
@ -26,34 +26,19 @@ namespace MpcNET
|
||||
public class MpcConnection : IMpcConnection
|
||||
{
|
||||
private static readonly Encoding Encoding = new UTF8Encoding();
|
||||
private readonly ICommandFactory commandFactory;
|
||||
private readonly IMpcConnectionReporter mpcConnectionReporter;
|
||||
private readonly IPEndPoint server;
|
||||
|
||||
private TcpClient tcpClient;
|
||||
private NetworkStream networkStream;
|
||||
|
||||
private string version;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MpcConnection"/> class.
|
||||
/// </summary>
|
||||
/// <param name="server">The server.</param>
|
||||
/// <param name="mpcConnectionReporter">The MPC connection reporter.</param>
|
||||
public MpcConnection(IPEndPoint server, IMpcConnectionReporter mpcConnectionReporter = null)
|
||||
: this(server, null, mpcConnectionReporter)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MpcConnection" /> class.
|
||||
/// </summary>
|
||||
/// <param name="server">The server.</param>
|
||||
/// <param name="commandFactory">The command factory.</param>
|
||||
/// <param name="mpcConnectionReporter">The MPC connection logger.</param>
|
||||
public MpcConnection(IPEndPoint server, ICommandFactory commandFactory, IMpcConnectionReporter mpcConnectionReporter = null)
|
||||
public MpcConnection(IPEndPoint server, IMpcConnectionReporter mpcConnectionReporter = null)
|
||||
{
|
||||
this.commandFactory = commandFactory ?? new CommandFactory();
|
||||
this.mpcConnectionReporter = mpcConnectionReporter;
|
||||
this.ClearConnectionFields();
|
||||
this.server = server ?? throw new ArgumentNullException("Server IPEndPoint not set.", nameof(server));
|
||||
@ -62,7 +47,7 @@ namespace MpcNET
|
||||
/// <summary>
|
||||
/// Gets the version.
|
||||
/// </summary>
|
||||
public string Version => this.version;
|
||||
public string Version { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Connects asynchronously.
|
||||
@ -95,19 +80,18 @@ namespace MpcNET
|
||||
/// Sends the command asynchronously.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResponse">The response type.</typeparam>
|
||||
/// <param name="commandSelector">The command selector.</param>
|
||||
/// <param name="mpcCommand">The MPC command.</param>
|
||||
/// <returns>
|
||||
/// The send task.
|
||||
/// </returns>
|
||||
public async Task<IMpdMessage<TResponse>> SendAsync<TResponse>(Func<ICommandFactory, IMpcCommand<TResponse>> commandSelector)
|
||||
public async Task<IMpdMessage<TResponse>> SendAsync<TResponse>(IMpcCommand<TResponse> mpcCommand)
|
||||
{
|
||||
if (this.tcpClient == null)
|
||||
{
|
||||
await this.ReconnectAsync(true);
|
||||
}
|
||||
|
||||
var command = commandSelector?.Invoke(this.commandFactory);
|
||||
if (command == null)
|
||||
if (mpcCommand == null)
|
||||
{
|
||||
throw new CommandNullException();
|
||||
}
|
||||
@ -115,7 +99,7 @@ namespace MpcNET
|
||||
Exception lastException = null;
|
||||
IReadOnlyList<string> response = new List<string>();
|
||||
var sendAttempter = new Attempter(3);
|
||||
var commandText = command.Serialize();
|
||||
var commandText = mpcCommand.Serialize();
|
||||
this.mpcConnectionReporter?.Sending(commandText);
|
||||
while (sendAttempter.Attempt())
|
||||
{
|
||||
@ -155,10 +139,10 @@ namespace MpcNET
|
||||
{
|
||||
}
|
||||
|
||||
return new ErrorMpdMessage<TResponse>(command, new ErrorMpdResponse<TResponse>(lastException));
|
||||
return new ErrorMpdMessage<TResponse>(mpcCommand, new ErrorMpdResponse<TResponse>(lastException));
|
||||
}
|
||||
|
||||
return new MpdMessage<TResponse>(command, true, response);
|
||||
return new MpdMessage<TResponse>(mpcCommand, true, response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -218,7 +202,7 @@ namespace MpcNET
|
||||
throw new MpcConnectException("Response of mpd does not start with \"" + Constants.FirstLinePrefix + "\".");
|
||||
}
|
||||
|
||||
this.version = firstLine.Substring(Constants.FirstLinePrefix.Length);
|
||||
this.Version = firstLine.Substring(Constants.FirstLinePrefix.Length);
|
||||
this.mpcConnectionReporter?.Connected(isReconnect, connectAttempter.CurrentAttempt, firstLine);
|
||||
}
|
||||
}
|
||||
@ -263,7 +247,7 @@ namespace MpcNET
|
||||
{
|
||||
this.networkStream?.Dispose();
|
||||
this.tcpClient?.Dispose();
|
||||
this.version = string.Empty;
|
||||
this.Version = string.Empty;
|
||||
this.tcpClient = null;
|
||||
this.networkStream = null;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<RootNamespace>MpcNET</RootNamespace>
|
||||
<Version>0.0.1-pre001</Version>
|
||||
<Version>0.0.1-pre005</Version>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<AssemblyVersion>0.0.1.0</AssemblyVersion>
|
||||
<FileVersion>0.0.1.0</FileVersion>
|
||||
@ -35,14 +35,10 @@
|
||||
<AdditionalFiles Include="stylecop.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Commands\StatusCommandFactory.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="Sundew.Base" Version="3.2.0-pre015" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
|
||||
<PackageReference Include="Sundew.Base" Version="3.2.0-pre024" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user