3.3.2 Command Lists

MPD makes provision for packaging-up multiple commands in one shot: command lists. To issue a command list rather than an individual command, specify a list of string instead of just a string:

(let ((conn (elmpd-connect :host "localhost")))
  (elmpd-send 
   conn
   '("random 1" "consume 1" "crossfade 5" "play")))

will send the following to the local MPD daemon:

command_list_begin
random 1
consume 1
crossfade 5
play
command_list_end

This presents a few options as to how the results can be processed if a callback is provided. The keyword argument :response selects among them:

  1. 'default: The command list will be initiated with command_list_begin (which results in a single response for the entire list). The callback will be invoked once in the same manner as simple commands: i.e. with the connection, result and either response or error message.
  2. 'list: The callback will be invoked once with the connection, a boolean result code, and a list of responses to each individual command in the list (the command list will be started with command_list_ok_begin producing a result for each command in the list).
  3. 'stream: The callback will be invoked once for each completed command in the list with three parameters: the connection, a boolean indicating success or failure, and the individual command result or error message (the command list will be started with command_list_ok_begin).
API: elmpd-send conn cmd cb kwargs

Send MPD command cmd on conn. If the optional cb is given, it shall be a callback to be invoked with the command results. The :response keyword argument describes the way in which the callback will be invoked for command lists. :response may be one of 'default (the default), 'list or 'stream.