COMMANDS 8.37 KB
Newer Older
Warren Dukes's avatar
Warren Dukes committed
1 2
                         Music Player Daemon - Commands

3 4 5 6 7 8 9 10 11
                                    WARNING
	This document has not been updated to reflect recent changes in
	the MPD protocol.  It does not contain all supported commands,
	and some commands may now take additional arguments.  However,
	clients conforming to this specification should still be
	compatible with the latest release of MPD.  For more up to date
	documentation, please see the protocol reference on the wiki at
	<http://mpd.wikia.com/wiki/Protocol_Reference>.

Warren Dukes's avatar
Warren Dukes committed
12 13 14 15 16 17
This document is intended for client developers, not end users.

Format:
-------

If arguments contain spaces, they should be surrounded by double quotation 
18
marks, ".  
Warren Dukes's avatar
Warren Dukes committed
19 20 21 22

command <type arg1> <type arg2> ...
	explanation: w/ arg1 and arg2

23 24 25 26 27 28 29 30
All data between the client and server is encoded in UTF-8. (Note,
that in UTF-8 all standard ansi characters, 0-127, are the same as a standard
ansi encoding. Also, no ansi character appears in any multi-byte
characters.  So, you can use standard C functions like strlen, and strcpy
just fine with UTF-8 encoded strings. For example: "OK\n" encoded in UTF-8 is
simply "OK\n".  For more information on UTF=8: 
http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 )

Warren Dukes's avatar
Warren Dukes committed
31 32 33 34 35 36
Command Completion:
-------------------

A command returns "OK\n" on completion or "ACK some error\n" on failure.
These denote the end of command execution.

37 38 39 40 41 42 43 44 45 46
NOTE:
-----

For manipulating playlists and playing, there are two sets of commands.  One
set uses the song id of a song in the playlist, while another set uses the
playlist position of the song.  The commands using song id's should be used
instead of the commands that manipulate and control playback based on playlist
position.  Using song id's is a safer method when multiple clients are 
interacting with MPD.

Warren Dukes's avatar
Warren Dukes committed
47 48 49
Commands:
---------

50 51 52 53
add <string path>
	add the file _path_ to the playlist (directories add recursively)
	_path_ can also be a single file
	increments playlist version by for each song added
Warren Dukes's avatar
Warren Dukes committed
54 55 56

clear	
	clears the current playlist
57
	increments playlist version by 1
Warren Dukes's avatar
Warren Dukes committed
58 59 60 61 62 63 64 65

clearerror	
	clear the current error message in status
	(this is also accomplished by any command that starts playback)

close
	close the connection with the MPD

Warren Dukes's avatar
Warren Dukes committed
66
crossfade <int seconds>
67
	sets crossfading between songs
Warren Dukes's avatar
Warren Dukes committed
68

69 70 71 72
currentsong
	displays the song info of current song (same song that is identified
	in status)

Warren Dukes's avatar
Warren Dukes committed
73 74
delete <int song>
	delete _song_ from playlist
75
	increments playlist version by 1
Warren Dukes's avatar
Warren Dukes committed
76

77 78 79 80
deleteid <int songid>
	delete song with _songid_ from playlist
	increments playlist version by 1

Warren Dukes's avatar
Warren Dukes committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
find <string type> <string what>
	finds songs in the db that are exactly _what_
	_type_ should be "album", "artist", or "title"
	_what_ is what to find

kill
	kill MPD

list <string type> <string arg1>
	list all tags of _type_ 
	_type_ should be "album" or "artist"
	_arg1_ is an optional parameter when type is album, this specifies
		to list albums by a artist, where artist is specified with
		arg1

96 97 98
listall <string path>
	lists all songs and directories in _path_ (recursively)
	_path_ is optional and maybe a directory or path
Warren Dukes's avatar
Warren Dukes committed
99

100
listallinfo <string path>
Warren Dukes's avatar
Warren Dukes committed
101 102 103
	same as listall command, except it also returns metadata info
	in the same format as lsinfo

Warren Dukes's avatar
Warren Dukes committed
104 105
load <string name>
	loads the playlist _name_.m3u from the playlist directory
106
	increments playlist version by the number of songs added
Warren Dukes's avatar
Warren Dukes committed
107 108 109 110 111 112

lsinfo <string directory>
	list contents of _directory_, from the db.  _directory_ is optional

move <int from> <int to>
	move song at _from_ to _to_ in the playlist
113
	increments playlist version by 1
Warren Dukes's avatar
Warren Dukes committed
114

Warren Dukes's avatar
Warren Dukes committed
115
moveid <int songid> <int to>
116 117 118
	move song with _songid_ to  _to_ in the playlist
	increments playlist version by 1

Warren Dukes's avatar
Warren Dukes committed
119 120 121
next
	plays next song in playlist

122 123
pause	<bool pause>
	toggle pause/resume playing
124
	_pause_ is required and should be 0 or 1
125
	NOTE: use of pause command w/o the _pause_ argument is deprecated
Warren Dukes's avatar
Warren Dukes committed
126

Warren Dukes's avatar
Warren Dukes committed
127 128 129 130 131 132 133
password <string password>
	this is used for authentication with the server.
	_password_ is simply the plaintext password

ping
	does nothing but return "OK"

Warren Dukes's avatar
Warren Dukes committed
134 135 136
play <int song>
	begin playing playlist at song number _song_, _song_ is optional

137 138 139
playid <int songid>
	begin playing playlist at song with _songid_, _songid_ is optional

Warren Dukes's avatar
Warren Dukes committed
140 141 142 143
playlist
	displays the current playlist
	NOTE: do not use this, instead use 'playlistinfo'

144 145
playlistinfo <int song>
	displays list of songs in the playlist
146
	_song_ is optional and specifies a single song to display info for
Warren Dukes's avatar
Warren Dukes committed
147

Warren Dukes's avatar
Warren Dukes committed
148
playlistid <int songid>
149
	displays list of songs in the playlist
150
	_songid_ is optional and specifies a single song to display info for
151

152 153 154
plchanges <playlist version>
	displays changed songs currently in the playlist since 
	_playlist version_
155 156
	NOTE: to detect songs that were deleted at the end of the playlist,
	use playlistlength returned by status command.
157

158 159 160 161 162 163 164
plchangesposid <playlist version>
	displays changed songs currently in the playlist since 
	_playlist version_
	This function only returns the position and the id of the changed song, not the complete metadata. This is more bandwidth efficient.
	NOTE: to detect songs that were deleted at the end of the playlist,
	use playlistlength returned by status command.

Warren Dukes's avatar
Warren Dukes committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
previous
	plays previous song in playlist

random <int state>
	set random state to _state_, _state_ should be 0 or 1

repeat <int state>
	set repeat state to _state_, _state_ should be 0 or 1

rm <string name>
	removes the playlist <name>.m3u from the playlist directory

save <string name>
	saves the current playlist to _name_.m3u in the playlist directory

search <string type> <string what>
Warren Dukes's avatar
Warren Dukes committed
181 182
	searches for any song that contain _what_
	_type_ can be "title","artist","album", or "filename"
Warren Dukes's avatar
Warren Dukes committed
183 184 185 186 187 188
	search is not case sensitive

seek <int song> <int time>
	seeks to the position _time_ (in seconds) of entry _song_ in the 
	playlist

189 190 191
seekid <int songid> <int time>
	seeks to the position _time_ (in seconds) of song with _songid_

192 193
setvol <int vol>
	set volume to _vol_
Warren Dukes's avatar
Warren Dukes committed
194
	_vol_ the range of volume is 0-100
195

Warren Dukes's avatar
Warren Dukes committed
196 197
shuffle
	shuffles the current playlist
198
	increments playlist version by 1
Warren Dukes's avatar
Warren Dukes committed
199 200 201 202 203 204 205

stats
	display stats
	artists: number of artists
	albums: number of albums
	songs: number of songs
	uptime: daemon uptime in seconds
Warren Dukes's avatar
Warren Dukes committed
206
	db_playtime: sum of all song times in db
Warren Dukes's avatar
Warren Dukes committed
207 208 209 210 211 212 213 214 215 216
	db_update: last db update in UNIX time
	playtime: time length of music played

status
	reports current status of player, and volume level.
	volume: (0-100).
	repeat: (0 or 1)
	playlist: (31-bit unsigned integer, the playlist version number)
	playlistlength: (integer, the length of the playlist)
	state: ("play", "stop", or "pause")
217 218
	song: (current song stopped on or playing, playlist song number)
	songid: (current song stopped on or playing, playlist songid)
Warren Dukes's avatar
Warren Dukes committed
219 220
	time: <int elapsed>:<time total> (of current playing/paused song)
	bitrate: <int bitrate> (instantaneous bitrate in kbps)
221 222
	xfade: <int seconds> (crossfade in seconds)
	audio: <int sampleRate>:<int bits>:<int channels>
223
	updatings_db: <int job id>
Warren Dukes's avatar
Warren Dukes committed
224 225 226 227 228 229 230
	error: if there is an error, returns message here

stop
	stop playing

swap <int song1> <int song2>
	swap positions of _song1_ and _song2_
231
	increments playlist version by 1
Warren Dukes's avatar
Warren Dukes committed
232

233 234 235 236
swapid <int songid1> <int songid2>
	swap positions of of songs with song id's of _songid1_ and _songid2_
	increments playlist version by 1

237
update <string path>
Warren Dukes's avatar
Warren Dukes committed
238
	searches mp3 directory for new music and removes old music from the db
239 240
	_path_ is an optional argument that maybe a particular directory or 
		song/file to update.
241 242 243 244
	returned:
		updating_db: <int job id>
	where job id, is the job id requested for your update, and is displayed
	in status, while the requested update is happening
245
	increments playlist version by 1
246
	NOTE: To update a number of paths/songs at once, use command_list,
247
	it will be much more faster/efficient.  Also, if you use a 
248 249
	command_list for updating, only one update_db job id will be returned
	per sequence of updates.
Warren Dukes's avatar
Warren Dukes committed
250 251 252

volume <int change>
	change volume by amount _change_
253
	NOTE: volume command is deprecated, use setvol instead
Warren Dukes's avatar
Warren Dukes committed
254 255 256 257 258 259 260 261 262

COMMAND LIST
------------

To facilitate faster adding of files, etc, you can pass a list of commands all
at once using a command list.  The command list beings with:

command_list_begin

263 264 265 266
or:

command_list_ok_begin

Warren Dukes's avatar
Warren Dukes committed
267 268 269 270 271 272 273
And ends with:

command_list_end

It does not execute any commands until the list has ended.  The return
value is whatever the return for a list of commands is.  On success
for all commands, OK is returned.  If a command fails, no more commands
274 275
are executed and the appropriate ACK error is returned. If "command_list_ok_begin is used", "list_OK\n" is returned for each successful command executed
in the command list.