MPD ProtocolVersion 0.11.02004Warren DukesProtocol OutlineThe MPD Protocol has Three Components: Commands, Responses, and Command Lists. All communication between the client and server uses the UTF-8 character encoding.Format of CommandsCommands in MPD are specified begginning with the name of the command. The arguments of a command are delimitted by spaces and should be surrounded by double qutotation marks. The end of a command is delimitted by a return character '\n'.command "arg1" "arg2"Format of ResponsesThe different response elements of a command are seperated by the return character '\n'. The last element of a response begin with either OK or ACK. Thus, if a command is successful, the end of the response is OK\n. If a command is unsuccessful ACK terminates the command with the following format:ACK {err#:cmd#} {command} some error messageerr# is an integer indicating the specific error that occured and cmd# is an integer indicating which command of the command list caused the error (See section 1.3 for more info on Command Lists). command gives the name of the command the error occurred on; however, its intended more for debugging persons (for human readability). some error message is also not intended to be parsed by clients but is intended more for debugging purposes.The other response elements are data. The data is seperated into a name and value pare by : . Thus, a possible command response containing data would be:Name1: Value1
Name2: Value2
OKCommand ListsCommand lists allow for a fast, effecient, and atomic execution of multiple commands. Command lists are initiated with either command_list_begin or command_list_ok_beginand are terminated with command_list_end.command_list_begin
command1 arg1 arg2
command2 arg1 arg2
command3 arg1 arg2
command_list_endThe responses for command executed with command lists are the same with the exception that anOK or ACK is not returned for each command. Instead a single OK or ACK is returned for the entire command list. An OK indicates that all the commands in the command list were successfully executed; while an ACK error is returned on the first unsuccessful command in the command list and none of the following commands in the command are executed.command_list_ok_begin responds with list_OK after each command is successfully completed. command_list_begin does not return anything between each command that is executed.CommandsDB: Browsing, Searching, and FindingBrowsing ResponsesBrowsing Responses usually contain groups of several responses. These groups are either begin with file, directory, or playlist. Each of these response groups maybe followed by metadata, which always begin with a capital letter (A-Z). Here's an example of a complete browsing response:file: Directory/file.mp3
Artist: Muscian
Album: Record
Time: 23
directory: Directory/Subdirectory
playlist: Directory/favorites
OKdirectory and playlist have no metadata, however future versions of the MPD protocol may add metadata to either. Also, future versions of MPD may add othe response groups for browsing.Song Info ResponsesFor query information on songs in the db (and the playlist), there is a common response for each song. The first response element is file. The remainng elements of the song info are one of the following metadata types: Artist, Album, Title, Track, Name, or Time.lsinfolsinfo
lsinfo directory
lsinfo filelsinfo responds with info for the directory or file specified. If lsinfo is called without any arguments then the root directory is implied as the path.listallinfolistallinfo
listallinfo directory
listallinfo filelistallinfo is a recursive form of
lsinfo
listalllistall
listall directory
listall filelistall is the same as
listallinfo
except that no metadata is returned.searchsearch filename pattern
search artist pattern
search album pattern
search title patternsearch respnds with the files that match the specified pattern with the specified data (either filename, artist, album, or title).findfind artist match
find album matchfind responds with the files whose artist or album are the same as match.listlist artist
list album
list album someArtistlist responds with the list of albums or artists in the db.Playlist: Adding, Deleting, and ManagmentAdditional Song MetadataIn addition to the same song metadata returned when browsing, songs in a playlist have two additional metadata elements. Pos is the position in the playlist of the song and Id is the playlist id for a song (each song in the playlist has a unique Id, even if there is a duplicate entry for the same file).file: directory/song
Artist: famousArtist
Title: popularSong
Num: 0
Id: 23
file: directory/song
Artist: famouseArtist
Title: popularSong
Num: 1
Id: 132Song ID's vs Playlist PositionWhen implementing a client for MPD, the developer must keep in mind that multiple clients maybe manipulating the playlist simultaneously. Thus, its essential to use playlist song id's instead of the playlist position for manipulating the playlist. This is due to the fact that another client maybe moving, deleting, etc... songs in the playlist, thus changing the order and positions of songs in the playlist. Consequently, using song id's is a safer method for manipulating the playlist as the song id's do not depend on the order and positions of songs in the playlist.playlistinfoplaylistinfo
playlistinfo -1
playlistinfo positionplaylistinfo responds with the information about songs in the playlist. If no argument is passed to playlistinfo or an argument of -1 is passed, then every song in the playlist is returned. If a playlist position is passed to playlistinfo, then the information about the song at position is returned. Note: It's suggest that
playlistid
be used instead of playlistinfo.playlistidplaylistid
playlistid -1
playlistid idplaylistid is the same as
playlistinfo
except that using optional argument id causes the information for the song with the playlist song ID idto be returned.plchangesplchanges versionplchanges responds with the song information for songs that have changed since the playlist version version. Note, to detect songs that were removed at the end of the playlist, use the playlist length returned by status.deleteiddeleteid iddeleteid removes the song with the playlist song id id from the playlist.deletedelete positiondelete removes the song at the playlist position position from the playlist. Note: It's suggested that
deleteid
be used instead of delete.addadd file
add urladd appends the file or url to the end of the playlistmoveidmovid idpositionmovemove positionpositionswapidswapid id1id2swapswap position1position2clearclearsavesaveshuffleshufflermrmStatus QueriesstatusstatuscurrentsongcurrentsongPlayback: Play, Pause, Stop, and Seekplayidplayid
playid -1
playid idplayplay
play -1
play positionpausepause 0
pause 1stopstopseekidseekid idsecondsseekseek positionsecondsrepeatrepeat 0
repeat 1randomrandom 0
random 1Miscellanous Commandspasswordpassword psswdstatsstatskillkillACK ErrorsCommon ErrorsCommand SpecificGuidelines