C# Class Libmpc.Mpc

The Mpc class implements all commands for the MPD. It takes care of command building and parsing the response into .net objects.
Exibir arquivo Open project: sakya/wpfmpdclient Class Usage Examples

Public Methods

Method Description
Add ( string filename ) : void

Adds a file to the playlist.

AddId ( string filename ) : int

Adds a file to the playlist and returns the id.

ChannelSendMessage ( string channel, string message ) : bool

Send a message to the specified channel.

ChannelSubscribe ( string channel ) : bool

Subscribe to a channel. The channel is created if it does not exist already. The name may consist of alphanumeric ASCII characters plus underscore, dash, dot and colon.

ChannelUnsubscribe ( string channel ) : bool

Unsubscribe from a channel.

Channels ( ) : List

Returns a list of all channels

Clear ( ) : void

Clears the playlist.

ClearError ( ) : void

Clears the error message set in the MPD.

Commands ( ) : List

Returns which commands the current user has access to.

Crossfade ( int seconds ) : void

Sets the seconds to crossfade between songs.

CurrentSong ( ) : MpdFile

Returns the information of the current song.

Delete ( int nr ) : void

Deletes the track with the given index from the current playlist.

DeleteId ( int id ) : void

Deletes the track with the given id from the current playlist.

DisableOutput ( int id ) : bool

Disables an MPD output.

EnableOutput ( int id ) : bool

Enables an MPD output.

Find ( string>.Dictionary search ) : List

Returns all files in the database who's attribute matches the given tokens. Works like the Search command but is case sensitive.

Find ( ScopeSpecifier scopeSpecifier, string token ) : List

Returns all files in the database who's attribute matches the given token. Works like the Search command but is case sensitive.

Idle ( Subsystems subsystems ) : void

Puts the client in idle mode for the given subsystems

You cannot send other commands to a client in idle mode

List ( ScopeSpecifier scopeSpecifier ) : List

Returns all values found in files of the MPD for the given attribute.

List ( ScopeSpecifier resultTag, ScopeSpecifier searchTag, string searchValue ) : List

Returns all values for the given attribute found in files of the MPD where another attribute matches a given value.

ListAll ( string path ) : List

Returns the names of all files and directory found under the given path.

ListAllInfo ( string path ) : List

Returns the information of all files found in the given path and its subdirectories.

ListPlaylist ( string name ) : List

Returns the filenames of the tracks in the given playlist.

ListPlaylistInfo ( string name ) : List

Return the meta data of the tracks in the given playlist.

ListPlaylists ( ) : List

Returns a list of the playlist directory.

Load ( string name ) : void

Loads the playlist with the given name.

LsInfo ( ) : MpdDirectoryListing

Returns the directory listing of the root directory.

LsInfo ( string path ) : MpdDirectoryListing

Returns the directory listing of the given path.

Move ( int oldNr, int newNr ) : void

Moves a track within the playlist.

MoveId ( int id, int nr ) : void

Moves a track within the playlist.

Mpc ( ) : System

Creates a new Mpc.

Next ( ) : void

Starts the playback of the next song in the playlist-

NotCommands ( ) : List

Returns which commands the current user does has access to.

Outputs ( ) : MpdOutput[]

Lists all outputs of the MPD.

Password ( string password ) : bool

Send the password to the server allow access to the server if enabled in the MPD.

Pause ( bool pause ) : void

Sets the MPD to pause or resume the playback.

Ping ( ) : void

Sends a ping command to the server and waits for the response.

PlChangesPosId ( int version ) : int>>.List

Returns the ids and positions of the changed tracks in the playlist since the given version.

Play ( ) : void

Starts the playback of the current item in the playlist.

Play ( int nr ) : void

Starts the playback of the item with the given index in the playlist.

PlayId ( ) : void

Starts the playback of the track in the playlist with the id 0.

PlayId ( int id ) : void

Starts the playback of the track in the playlist with the given id.

PlaylistAdd ( string name, string file ) : void

Add a file to a playlist.

PlaylistClear ( string name ) : void

Clears all tracks from a playlist.

PlaylistDelete ( string name, int id ) : void

Delete a file from a playlist.

PlaylistFind ( ScopeSpecifier scopeSpecifier, string token ) : List

Returns the meta data for all tracks in the current playlist whos attribute equals the given value.

PlaylistId ( ) : List

Returns the meta data of the items in the current playlist.

PlaylistId ( int id ) : MpdFile

Returns the meta data of a track in the current playlist.

PlaylistInfo ( ) : List

Returns the meta data of the items in the current playlist.

PlaylistInfo ( int nr ) : MpdFile

Returns the meta data of a track in the current playlist.

PlaylistMove ( string name, int id, int nr ) : void

Moves a track in a playlist.

PlaylistSearch ( ScopeSpecifier scopeSpecifier, string token ) : List

Returns the meta data for all tracks in the current playlist whos attribute contains the given value.

Plchanges ( int version ) : List

Returns all changed tracks in the playlist since the given version.

Previous ( ) : void

Starts the playback of the previous track in the playlist.

Random ( bool random ) : void

Sets the MPD to random or sequential playback.

ReadChannelsMessages ( ) : List

Reads messages for this client.

Rename ( string oldName, string newName ) : void

Renames a playlist.

Repeat ( bool repeat ) : void

Sets if the MPD should repeat the playlist.

Rm ( string name ) : void

Removes the playlist with the given name.

Save ( string name ) : void

Saves the current playlist with the given name.

Search ( ScopeSpecifier scopeSpecifier, string token ) : List

Returns all files in the database who's attribute matches the given token. Works like the Find command but is case insensitive.

Seek ( int nr, int time ) : void

Starts playback of a given song at the give position.

SeekId ( int id, int time ) : void

Starts playback of a given song at the give position.

SetVol ( int vol ) : void

Sets the output volume of the MPD.

Shuffle ( ) : void

Shuffles the current playlist.

Stats ( ) : MpdStatistics

Requests the current statistics from the MPD,

Status ( ) : MpdStatus

Returns the current status of the MPD.

Stop ( ) : void

Stops the playback of the MPD.

Swap ( int nr1, int nr2 ) : void

Swaps the to tracks in the current playlist.

SwapId ( int id1, int id2 ) : void

Swaps the to tracks in the current playlist.

TagTypes ( ) : string[]

Returns the list of tag types the MPD supports.

Update ( ) : int

Starts an update of the MPD database.

Private Methods

Method Description
EscapeString ( string input ) : string
IdleThread ( object state ) : void
OnSubsystemsChangedHandler ( MpcConnection connection, Mpc subsystems ) : void
getConnection ( ) : MpcConnection
onMpcConnectionConnected ( MpcConnection connection ) : void
onMpcConnectionDisconnected ( MpcConnection connection ) : void
toTag ( ScopeSpecifier scopeSpecifier ) : string

Method Details

Add() public method

Adds a file to the playlist.
public Add ( string filename ) : void
filename string The name and path of the file to add.
return void

AddId() public method

Adds a file to the playlist and returns the id.
public AddId ( string filename ) : int
filename string The name and path of the file to add.
return int

ChannelSendMessage() public method

Send a message to the specified channel.
public ChannelSendMessage ( string channel, string message ) : bool
channel string
message string
return bool

ChannelSubscribe() public method

Subscribe to a channel. The channel is created if it does not exist already. The name may consist of alphanumeric ASCII characters plus underscore, dash, dot and colon.
public ChannelSubscribe ( string channel ) : bool
channel string
return bool

ChannelUnsubscribe() public method

Unsubscribe from a channel.
public ChannelUnsubscribe ( string channel ) : bool
channel string
return bool

Channels() public method

Returns a list of all channels
public Channels ( ) : List
return List

Clear() public method

Clears the playlist.
public Clear ( ) : void
return void

ClearError() public method

Clears the error message set in the MPD.
public ClearError ( ) : void
return void

Commands() public method

Returns which commands the current user has access to.
public Commands ( ) : List
return List

Crossfade() public method

Sets the seconds to crossfade between songs.
public Crossfade ( int seconds ) : void
seconds int The seconds to crossfade between songs.
return void

CurrentSong() public method

Returns the information of the current song.
public CurrentSong ( ) : MpdFile
return MpdFile

Delete() public method

Deletes the track with the given index from the current playlist.
public Delete ( int nr ) : void
nr int The index of the track to remove from the playlist.
return void

DeleteId() public method

Deletes the track with the given id from the current playlist.
public DeleteId ( int id ) : void
id int The id of the track to remove from the playlist.
return void

DisableOutput() public method

Disables an MPD output.
public DisableOutput ( int id ) : bool
id int The id of the output.
return bool

EnableOutput() public method

Enables an MPD output.
public EnableOutput ( int id ) : bool
id int The id of the output.
return bool

Find() public method

Returns all files in the database who's attribute matches the given tokens. Works like the Search command but is case sensitive.
public Find ( string>.Dictionary search ) : List
search string>.Dictionary The values the files attribute must have to be included in the result.
return List

Find() public method

Returns all files in the database who's attribute matches the given token. Works like the Search command but is case sensitive.
public Find ( ScopeSpecifier scopeSpecifier, string token ) : List
scopeSpecifier ScopeSpecifier Specifies the attribute to search for.
token string The value the files attribute must have to be included in the result.
return List

Idle() public method

Puts the client in idle mode for the given subsystems
You cannot send other commands to a client in idle mode
public Idle ( Subsystems subsystems ) : void
subsystems Subsystems The subsystems to listen to.
return void

List() public method

Returns all values found in files of the MPD for the given attribute.
public List ( ScopeSpecifier scopeSpecifier ) : List
scopeSpecifier ScopeSpecifier The attribute who's values are requested.
return List

List() public method

Returns all values for the given attribute found in files of the MPD where another attribute matches a given value.
public List ( ScopeSpecifier resultTag, ScopeSpecifier searchTag, string searchValue ) : List
resultTag ScopeSpecifier The attribute whos values are returns.
searchTag ScopeSpecifier The attribute whos value should match a given value for the file to be included in the result.
searchValue string The value the searchTag attribute must match for the file to be included in the result.
return List

ListAll() public method

Returns the names of all files and directory found under the given path.
public ListAll ( string path ) : List
path string The path whos subdirectories and their files are requested.
return List

ListAllInfo() public method

Returns the information of all files found in the given path and its subdirectories.
public ListAllInfo ( string path ) : List
path string The path of which the file information is requested.
return List

ListPlaylist() public method

Returns the filenames of the tracks in the given playlist.
public ListPlaylist ( string name ) : List
name string The playlist whos filename are requested.
return List

ListPlaylistInfo() public method

Return the meta data of the tracks in the given playlist.
public ListPlaylistInfo ( string name ) : List
name string The playlist whos files meta data are requested.
return List

ListPlaylists() public method

Returns a list of the playlist directory.
public ListPlaylists ( ) : List
return List

Load() public method

Loads the playlist with the given name.
public Load ( string name ) : void
name string The name of the playlist to load.
return void

LsInfo() public method

Returns the directory listing of the root directory.
public LsInfo ( ) : MpdDirectoryListing
return MpdDirectoryListing

LsInfo() public method

Returns the directory listing of the given path.
public LsInfo ( string path ) : MpdDirectoryListing
path string The path whos listing is requested.
return MpdDirectoryListing

Move() public method

Moves a track within the playlist.
public Move ( int oldNr, int newNr ) : void
oldNr int The old index of the track in the playlist.
newNr int The new index of the track in the playlist.
return void

MoveId() public method

Moves a track within the playlist.
public MoveId ( int id, int nr ) : void
id int The id of the track to move.
nr int The new index of the track in the playlist.
return void

Mpc() public method

Creates a new Mpc.
public Mpc ( ) : System
return System

Next() public method

Starts the playback of the next song in the playlist-
public Next ( ) : void
return void

NotCommands() public method

Returns which commands the current user does has access to.
public NotCommands ( ) : List
return List

Outputs() public method

Lists all outputs of the MPD.
public Outputs ( ) : MpdOutput[]
return MpdOutput[]

Password() public method

Send the password to the server allow access to the server if enabled in the MPD.
public Password ( string password ) : bool
password string The password to authorize to the server.
return bool

Pause() public method

Sets the MPD to pause or resume the playback.
public Pause ( bool pause ) : void
pause bool If the playback should be paused or resumed.
return void

Ping() public method

Sends a ping command to the server and waits for the response.
public Ping ( ) : void
return void

PlChangesPosId() public method

Returns the ids and positions of the changed tracks in the playlist since the given version.
public PlChangesPosId ( int version ) : int>>.List
version int
return int>>.List

Play() public method

Starts the playback of the current item in the playlist.
public Play ( ) : void
return void

Play() public method

Starts the playback of the item with the given index in the playlist.
public Play ( int nr ) : void
nr int The index of the track in the playlist to start playing.
return void

PlayId() public method

Starts the playback of the track in the playlist with the id 0.
public PlayId ( ) : void
return void

PlayId() public method

Starts the playback of the track in the playlist with the given id.
public PlayId ( int id ) : void
id int The id of the track to start playing.
return void

PlaylistAdd() public method

Add a file to a playlist.
public PlaylistAdd ( string name, string file ) : void
name string The name of the playlist.
file string The path and name of the file to add.
return void

PlaylistClear() public method

Clears all tracks from a playlist.
public PlaylistClear ( string name ) : void
name string The name of the playlist to clear.
return void

PlaylistDelete() public method

Delete a file from a playlist.
public PlaylistDelete ( string name, int id ) : void
name string The name of the playlist
id int The id of the track to delete.
return void

PlaylistFind() public method

Returns the meta data for all tracks in the current playlist whos attribute equals the given value.
public PlaylistFind ( ScopeSpecifier scopeSpecifier, string token ) : List
scopeSpecifier ScopeSpecifier The attribute to search for the given value.
token string The value to search for in the given attribute.
return List

PlaylistId() public method

Returns the meta data of the items in the current playlist.
public PlaylistId ( ) : List
return List

PlaylistId() public method

Returns the meta data of a track in the current playlist.
public PlaylistId ( int id ) : MpdFile
id int The id of the track in the playlist.
return MpdFile

PlaylistInfo() public method

Returns the meta data of the items in the current playlist.
public PlaylistInfo ( ) : List
return List

PlaylistInfo() public method

Returns the meta data of a track in the current playlist.
public PlaylistInfo ( int nr ) : MpdFile
nr int The index of the track in the playlist.
return MpdFile

PlaylistMove() public method

Moves a track in a playlist.
public PlaylistMove ( string name, int id, int nr ) : void
name string The name of the playlist.
id int The id of the track to move.
nr int The position to move the track to.
return void

PlaylistSearch() public method

Returns the meta data for all tracks in the current playlist whos attribute contains the given value.
public PlaylistSearch ( ScopeSpecifier scopeSpecifier, string token ) : List
scopeSpecifier ScopeSpecifier The attribute to search for the given value.
token string The value to search for in the given attribute.
return List

Plchanges() public method

Returns all changed tracks in the playlist since the given version.
public Plchanges ( int version ) : List
version int The version number.
return List

Previous() public method

Starts the playback of the previous track in the playlist.
public Previous ( ) : void
return void

Random() public method

Sets the MPD to random or sequential playback.
public Random ( bool random ) : void
random bool If the MPD playlist should be played randomly.
return void

ReadChannelsMessages() public method

Reads messages for this client.
public ReadChannelsMessages ( ) : List
return List

Rename() public method

Renames a playlist.
public Rename ( string oldName, string newName ) : void
oldName string The old name of the playlist.
newName string The new name of the playlist.
return void

Repeat() public method

Sets if the MPD should repeat the playlist.
public Repeat ( bool repeat ) : void
repeat bool If the MPD should repeat the playlist.
return void

Rm() public method

Removes the playlist with the given name.
public Rm ( string name ) : void
name string The name of the playlist to remove.
return void

Save() public method

Saves the current playlist with the given name.
public Save ( string name ) : void
name string The name to the save the currenty playlist.
return void

Search() public method

Returns all files in the database who's attribute matches the given token. Works like the Find command but is case insensitive.
public Search ( ScopeSpecifier scopeSpecifier, string token ) : List
scopeSpecifier ScopeSpecifier Specifies the attribute to search for.
token string The value the files attribute must have to be included in the result.
return List

Seek() public method

Starts playback of a given song at the give position.
public Seek ( int nr, int time ) : void
nr int The index of the song in the playlist.
time int The number of seconds to start playback on.
return void

SeekId() public method

Starts playback of a given song at the give position.
public SeekId ( int id, int time ) : void
id int The id of the song in the playlist.
time int The number of seconds to start playback on.
return void

SetVol() public method

Sets the output volume of the MPD.
public SetVol ( int vol ) : void
vol int The output volume of the MPD between 0 and 100.
return void

Shuffle() public method

Shuffles the current playlist.
public Shuffle ( ) : void
return void

Stats() public method

Requests the current statistics from the MPD,
public Stats ( ) : MpdStatistics
return MpdStatistics

Status() public method

Returns the current status of the MPD.
public Status ( ) : MpdStatus
return MpdStatus

Stop() public method

Stops the playback of the MPD.
public Stop ( ) : void
return void

Swap() public method

Swaps the to tracks in the current playlist.
public Swap ( int nr1, int nr2 ) : void
nr1 int The index of the first track.
nr2 int The index of the second track.
return void

SwapId() public method

Swaps the to tracks in the current playlist.
public SwapId ( int id1, int id2 ) : void
id1 int The id of the first track.
id2 int The id of the second track.
return void

TagTypes() public method

Returns the list of tag types the MPD supports.
public TagTypes ( ) : string[]
return string[]

Update() public method

Starts an update of the MPD database.
public Update ( ) : int
return int