Basic


Data Structures

struct  _MpdData

Defines

#define TRUE   1
#define FALSE   0

Typedefs

typedef struct _MpdObj MpdObj
typedef void(* StatusChangedCallback )(MpdObj *mi, ChangedStatusType what, void *userdata)
typedef int(* ErrorCallback )(MpdObj *mi, int id, char *msg, void *userdata)
typedef void(* ConnectionChangedCallback )(MpdObj *mi, int connect, void *userdata)

Enumerations

enum  MpdError {
  MPD_OK = 0, MPD_ARGS_ERROR = -5, MPD_NOT_CONNECTED = -10, MPD_STATUS_FAILED = -20,
  MPD_LOCK_FAILED = -30, MPD_STATS_FAILED = -40, MPD_SERVER_ERROR = -50, MPD_SERVER_NOT_SUPPORTED = -51,
  MPD_DATABASE_PLAYLIST_EXIST = -60, MPD_PLAYLIST_EMPTY = -70, MPD_PLAYLIST_QUEUE_EMPTY = -75, MPD_PLAYER_NOT_PLAYING = -80,
  MPD_TAG_NOT_FOUND = -90, MPD_FATAL_ERROR = -1000
}
enum  MpdServerCommand { MPD_SERVER_COMMAND_ALLOWED = TRUE, MPD_SERVER_COMMAND_NOT_ALLOWED = FALSE, MPD_SERVER_COMMAND_NOT_SUPPORTED = -1, MPD_SERVER_COMMAND_ERROR = -2 }
enum  ChangedStatusType {
  MPD_CST_PLAYLIST = 0x0001, MPD_CST_SONGPOS = 0x0002, MPD_CST_SONGID = 0x0004, MPD_CST_DATABASE = 0x0008,
  MPD_CST_UPDATING = 0x0010, MPD_CST_VOLUME = 0x0020, MPD_CST_TOTAL_TIME = 0x0040, MPD_CST_ELAPSED_TIME = 0x0080,
  MPD_CST_CROSSFADE = 0x0100, MPD_CST_RANDOM = 0x0200, MPD_CST_REPEAT = 0x0400, MPD_CST_AUDIO = 0x0800,
  MPD_CST_STATE = 0x1000, MPD_CST_PERMISSION = 0x2000, MPD_CST_BITRATE = 0x4000, MPD_CST_AUDIOFORMAT = 0x8000,
  MPD_CST_STORED_PLAYLIST = 0x20000, MPD_CST_SERVER_ERROR = 0x40000, MPD_CST_OUTPUT = 0x80000, MPD_CST_STICKER = 0x100000
}

Functions

MpdObjmpd_new_default ()
MpdObjmpd_new (char *hostname, int port, char *password)
int mpd_set_hostname (MpdObj *mi, char *hostname)
const char * mpd_get_hostname (MpdObj *mi)
int mpd_set_password (MpdObj *mi, const char *password)
int mpd_set_port (MpdObj *mi, int port)
int mpd_set_connection_timeout (MpdObj *mi, float timeout)
int mpd_connect_real (MpdObj *mi, mpd_Connection *connection)
int mpd_connect (MpdObj *mi)
int mpd_disconnect (MpdObj *mi)
int mpd_check_connected (MpdObj *mi)
int mpd_check_error (MpdObj *mi)
void mpd_free (MpdObj *mi)
int mpd_send_password (MpdObj *mi)
void mpd_signal_connect_status_changed (MpdObj *mi, StatusChangedCallback status_changed, void *userdata)
void mpd_signal_connect_error (MpdObj *mi, ErrorCallback error, void *userdata)
void mpd_signal_connect_connection_changed (MpdObj *mi, ConnectionChangedCallback connection_changed, void *userdata)

Variables

char * libmpd_version

Define Documentation

#define FALSE   0

Defined for readability: False is 0.

Definition at line 49 of file libmpd.h.

#define TRUE   1

Defined for readability: True is 1.

Definition at line 44 of file libmpd.h.


Typedef Documentation

typedef void(* ConnectionChangedCallback)(MpdObj *mi, int connect, void *userdata)

Parameters:
mi a MpdObj
connect 1 if you are now connected, 0 if you are disconnected.
userdata user data set when the signal handler was connected. Signal is triggered when the connection state changes.

Definition at line 423 of file libmpd.h.

typedef int(* ErrorCallback)(MpdObj *mi, int id, char *msg, void *userdata)

Parameters:
mi a MpdObj
id The error Code.
msg human-readable informative error message.
userdata user data set when the signal handler was connected. This signal is called when an error has occurred in the communication with mpd.
return: TRUE if libmpd should disconnect.
Examples:
testcase.c.

Definition at line 412 of file libmpd.h.

typedef struct _MpdObj MpdObj

The Main Mpd Object. Don't access any of the internal values directly, but use the provided functions.

Examples:
testcase.c.

Definition at line 97 of file libmpd.h.

typedef void(* StatusChangedCallback)(MpdObj *mi, ChangedStatusType what, void *userdata)

Parameters:
mi a MpdObj
what a ChangedStatusType that determines what changed triggered the signal. This is a bitmask.
userdata user data set when the signal handler was connected.
Signal that gets called when the state of mpd has changed. Look ChangedStatusType to see the possible events.
Examples:
testcase.c.

Definition at line 398 of file libmpd.h.


Enumeration Type Documentation

Bitwise enumeration to determine what triggered the status_changed signals This is used in combination with the StatusChangedCallback

 void status_changed_callback(MpdObj *mi, ChangedStatusType what)
 {
        if(what&MPD_CST_SONGID)
        {
                // act on song change 

        }
        if(what&MPD_CST_RANDOM)
        {
                // act on random change
        }
        // etc.
 }
Enumerator:
MPD_CST_PLAYLIST  The playlist has changed
MPD_CST_SONGPOS  The song position of the playing song has changed
MPD_CST_SONGID  The songid of the playing song has changed
MPD_CST_DATABASE  The database has changed.
MPD_CST_UPDATING  the state of updating the database has changed.
MPD_CST_VOLUME  the volume has changed
MPD_CST_TOTAL_TIME  The total time of the currently playing song has changed
MPD_CST_ELAPSED_TIME  The elapsed time of the current song has changed.
MPD_CST_CROSSFADE  The crossfade time has changed.
MPD_CST_RANDOM  The random state is changed.
MPD_CST_REPEAT  repeat state is changed.
MPD_CST_AUDIO  Not implemented
MPD_CST_STATE  The state of the player has changed.
MPD_CST_PERMISSION  The permissions the client has, has changed.
MPD_CST_BITRATE  The bitrate of the playing song has changed.
MPD_CST_AUDIOFORMAT  the audio format of the playing song changed.
MPD_CST_STORED_PLAYLIST  the queue has changed
MPD_CST_SERVER_ERROR  server error
MPD_CST_OUTPUT  output changed
MPD_CST_STICKER  Sticker changed

Definition at line 346 of file libmpd.h.

enum MpdError

Enum that represent the errors libmpd functions can return

Enumerator:
MPD_OK  Command/function completed succesfull
MPD_ARGS_ERROR  Error in the function's arguments
MPD_NOT_CONNECTED  Action failed because there is no connection to an mpd daemon
MPD_STATUS_FAILED  Failed to grab status
MPD_LOCK_FAILED  Connection is still locked
MPD_STATS_FAILED  Failed to grab status
MPD_SERVER_ERROR  Mpd server returned an error
MPD_SERVER_NOT_SUPPORTED  Mpd doesn't support this feature
MPD_DATABASE_PLAYLIST_EXIST  The playlist already exists
MPD_PLAYLIST_EMPTY  Playlist is empty
MPD_PLAYLIST_QUEUE_EMPTY  Playlist queue is empty
MPD_PLAYER_NOT_PLAYING  Player isn't Playing
MPD_TAG_NOT_FOUND  Tag Item not found
MPD_FATAL_ERROR  Fatal error, something I am not sure what todo with

Definition at line 58 of file libmpd.h.

enum that represents the state of a command.

Enumerator:
MPD_SERVER_COMMAND_ALLOWED 
MPD_SERVER_COMMAND_NOT_ALLOWED 
MPD_SERVER_COMMAND_NOT_SUPPORTED 
MPD_SERVER_COMMAND_ERROR 

Definition at line 103 of file libmpd.h.


Function Documentation

int mpd_check_connected ( MpdObj mi  ) 

Parameters:
mi a MpdObj
Checks if MpdObj is connected
Returns:
True when connected

int mpd_check_error ( MpdObj mi  ) 

Parameters:
mi a MpdObj
Checks if there was an error
Returns:
True when there is an error

int mpd_connect ( MpdObj mi  ) 

Parameters:
mi a MpdObj
Connect to the mpd daemon. Warning: mpd_connect connects anonymous, to authenticate use mpd_send_password

Returns:
returns a MpdError, MPD_OK when successful
Examples:
testcase.c.

int mpd_connect_real ( MpdObj mi,
mpd_Connection connection 
)

int mpd_disconnect ( MpdObj mi  ) 

Parameters:
mi The MpdObj to disconnect
Disconnect the current connection
Returns:
MPD_OK (always)

void mpd_free ( MpdObj mi  ) 

Parameters:
mi a MpdObj
Free the MpdObj, when still connected the connection will be disconnected first
Examples:
testcase.c.

const char* mpd_get_hostname ( MpdObj mi  ) 

Parameters:
mi a MpdObj
gets the set hostname

Returns:
a const char representing the hostname

MpdObj* mpd_new ( char *  hostname,
int  port,
char *  password 
)

Parameters:
hostname The hostname to connect to
port The port to connect to
password The password to use for the connection, or NULL for no password
Create a new MpdObj with provided settings:

Returns:
the new MpdObj
Examples:
testcase.c.

MpdObj* mpd_new_default (  ) 

mpd_new_default

Create a new MpdObj with default settings. Hostname will be set to "localhost". Port will be 6600.

same as calling:

 mpd_new("localhost",6600,NULL);

Returns:
the new MpdObj

int mpd_send_password ( MpdObj mi  ) 

Parameters:
mi a MpdObj
Forces libmpd to re-authenticate itself.

When successful it will trigger the "permission" changed signal.

Returns:
: a MpdError
Examples:
testcase.c.

int mpd_set_connection_timeout ( MpdObj mi,
float  timeout 
)

Parameters:
mi a MpdObj
timeout,: A timeout (in seconds)
Set the timeout of the connection. If already connected the timeout of the running connection

Returns:
a MpdError. (MPD_OK if everything went ok)
Examples:
testcase.c.

int mpd_set_hostname ( MpdObj mi,
char *  hostname 
)

Parameters:
mi a MpdObj
hostname The new hostname to use
set the hostname

Returns:
a MpdError. (MPD_OK if everything went ok)

int mpd_set_password ( MpdObj mi,
const char *  password 
)

Parameters:
mi a MpdObj
password The new password to use
Set the password

Returns:
a MpdError. (MPD_OK if everything went ok)
Examples:
testcase.c.

int mpd_set_port ( MpdObj mi,
int  port 
)

Parameters:
mi a MpdObj
port The port to use. (Default: 6600)
Set the Port number

Returns:
a MpdError. (MPD_OK if everything went ok)

void mpd_signal_connect_connection_changed ( MpdObj mi,
ConnectionChangedCallback  connection_changed,
void *  userdata 
)

Parameters:
mi a MpdObj
connection_changed a ConnectionChangedCallback
userdata user data passed to the callback

void mpd_signal_connect_error ( MpdObj mi,
ErrorCallback  error,
void *  userdata 
)

Parameters:
mi a MpdObj
error a ErrorCallback
userdata user data passed to the callback
Examples:
testcase.c.

void mpd_signal_connect_status_changed ( MpdObj mi,
StatusChangedCallback  status_changed,
void *  userdata 
)

Parameters:
mi a MpdObj
status_changed a StatusChangedCallback
userdata user data passed to the callback
Examples:
testcase.c.


Variable Documentation


Copyright 2006 Qball Cow