Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

MpdCom Class Reference

MpdCom class for communication with the Music Player Daemon. More...

#include <mpdcom.h>

List of all members.

Public Types

enum  responcetype {
  CONNECTING, SIMPLE, PLAYLIST, PLAYLIST_INFO,
  STATUS, FILELIST
}
enum  mpdstate { PLAY, STOP, PAUSE }

Public Slots

void previous (void)
 Plays the previous song. More...

void next (void)
 Plays the next song. More...

void stop (void)
 Stops playing. More...

void play (void)
 Starts playing. More...

void play (int)
 Starts playing a specific song. More...

void pause (void)
 Pauses the playback. More...

void seek (int songnr, int pos)
 Seeks a position in a specific song. More...

void volume (int perc)
 Sets the volume. More...

void repeat (bool)
 Toggles repeat. More...

void random (bool)
 Toggles random. More...

void update (void)
 Sends the update command. More...

void crossFade (int)
 Sets the crossfade amount. More...

void requestPlaylist (void)
 Retrieves the playlist. More...

void loadPlaylist (QString, bool=false)
 Loads a playlist. More...

void clearPlaylist (void)
 Clears the current playlist. More...

void deletePlaylist (QString)
 Deletes a playlist. More...

void requestSongInfo (unsigned)
 Requests songinformation about a specific song. More...

void requestStatusUpdate (void)
 Requests the current status. More...

void requestDirectoryContent (QString dir="")
 Requests the content of a directory. More...

void addFile (QString)
 Adds a song to the playlist. More...

void removeFile (QString)
 Removes a song from the playlist. More...

void swap (unsigned, unsigned)
 Swaps two songs in the playlist. More...


Signals

void playlistUpdate (const Playlist &p)
 Sends a received playlist.
Parameters:
p  the new playlist.
More...


void statusUpdate (const MpdCom::Status &s)
 Sends new status information.
Parameters:
s  the new status.
More...


void error (const QString &e)
 Sends error information.
Parameters:
e  the error message.
More...


void directoryContent (const MpdCom::Filelist &f)
 Sends received directorycontent.
Parameters:
f  the filelist.
More...



Public Methods

 MpdCom (const char *hostname, int hostport, bool needsPlayList, QObject *)
 Constructs an instance of this class. More...

void reconnectCom (const char *hostname, int hostport)
 Reconnects to a diffrent server. More...

void disconnectCom (void)
 Disconnect from the server. More...

void connectCom (void)
 Connect to the server. More...

bool minVersion (QString)
 Returns true if the connected version of MPD is higher of equel to the given version. More...

QString getVersion (void)
void startCommandList (void)
void endCommandList (void)

Protected Slots

void slotReadyRead (void)
 Reads from the socket. This function handles all incoming data from MPD. More...

void slotConnected (void)
 Logs connection establishments. More...

void slotError (int)
 Logs connection errors. More...

void slotReconnect (void)
 Reconnects with the server. More...

void slotConnectionClosed (void)
 Logs connection closes. More...


Detailed Description

MpdCom class for communication with the Music Player Daemon.

The communication with MPD is asynchronic which makes it possible to comunicate without stalling of the application. This class tries to wrap around differences in MPD versions as much as posible.

Author:
ing. A.E. van Putten
Date:
01-01-2004


Member Enumeration Documentation

enum mpdstate
 

Enumeration values:
PLAY 
STOP 
PAUSE 

enum responcetype
 

Enumeration values:
CONNECTING 
SIMPLE 
PLAYLIST 
PLAYLIST_INFO 
STATUS 
FILELIST 


Constructor & Destructor Documentation

MpdCom const char *    hostname,
int    hostport,
bool    needsPlayList,
QObject *    parent = 0
 

Constructs an instance of this class.

Parameters:
hostname  the host to connect to
hostport  the port on the host to connect to
needsPlayList  whether an automatic update of the playlist is needed
parent  a parent, defaults to NULL


Member Function Documentation

void addFile QString    name [slot]
 

Adds a song to the playlist.

Directories are only supported from MPD 0.10+.

Parameters:
name  the file/dir to add

void clearPlaylist void    [slot]
 

Clears the current playlist.

void connectCom void   
 

Connect to the server.

void crossFade int    sec [slot]
 

Sets the crossfade amount.

Only works on MPD 0.10+

Parameters:
sec  the amount of seconds to crossfade

void deletePlaylist QString    playlist [slot]
 

Deletes a playlist.

Parameters:
playlist  the playlist to remove

void directoryContent const MpdCom::Filelist   f [signal]
 

Sends received directorycontent.

Parameters:
f  the filelist.

void disconnectCom void   
 

Disconnect from the server.

void endCommandList void    [inline]
 

End a command list and send the list to MPD

void error const QString &    e [signal]
 

Sends error information.

Parameters:
e  the error message.

QString getVersion void    [inline]
 

Returns the version of MPD

void loadPlaylist QString    playlistname,
bool    enqueue = false
[slot]
 

Loads a playlist.

Parameters:
playlistname  filename of the playlist without extension
enqueue  if true the current playlist is not cleared

bool minVersion QString    ver
 

Returns true if the connected version of MPD is higher of equel to the given version.

Parameters:
ver  the version to compare with

void next void    [slot]
 

Plays the next song.

void pause void    [slot]
 

Pauses the playback.

void play int    songnr [slot]
 

Starts playing a specific song.

Parameters:
songnr  the song to play

void play void    [slot]
 

Starts playing.

void playlistUpdate const Playlist   p [signal]
 

Sends a received playlist.

Parameters:
p  the new playlist.

void previous void    [slot]
 

Plays the previous song.

void random bool    [slot]
 

Toggles random.

void reconnectCom const char *    hostname,
int    hostport
 

Reconnects to a diffrent server.

Parameters:
hostname  the new hostname
hostport  the new port on the host

void removeFile QString    index [slot]
 

Removes a song from the playlist.

Parameters:
index  the song to remove

void repeat bool    [slot]
 

Toggles repeat.

void requestDirectoryContent QString    dir = "" [slot]
 

Requests the content of a directory.

Parameters:
dir  the target directory

void requestPlaylist void    [slot]
 

Retrieves the playlist.

void requestSongInfo unsigned    index [slot]
 

Requests songinformation about a specific song.

Parameters:
index  the index of the song

void requestStatusUpdate void    [slot]
 

Requests the current status.

void seek int    songnr,
int    pos
[slot]
 

Seeks a position in a specific song.

Parameters:
songnr  the song to play
pos  the position in the song

void slotConnected void    [protected, slot]
 

Logs connection establishments.

void slotConnectionClosed void    [protected, slot]
 

Logs connection closes.

void slotError int    e [protected, slot]
 

Logs connection errors.

Parameters:
e  the error number

void slotReadyRead void    [protected, slot]
 

Reads from the socket. This function handles all incoming data from MPD.

void slotReconnect void    [protected, slot]
 

Reconnects with the server.

void startCommandList void    [inline]
 

Starts a command list, all simple commands are stored and transfered when the endCommandList function is executed.

void statusUpdate const MpdCom::Status   s [signal]
 

Sends new status information.

Parameters:
s  the new status.

void stop void    [slot]
 

Stops playing.

void swap unsigned    index1,
unsigned    index2
[slot]
 

Swaps two songs in the playlist.

Parameters:
index1  the index of the first song
index2  the index of the second song

void update void    [slot]
 

Sends the update command.

void volume int    perc [slot]
 

Sets the volume.

This function is version independant, MPD versions below 0.10 work with relative values. The absolute values of this function are translated for older versions.

Parameters:
volume  the absolute value for the volume ranging between 0 and 100


The documentation for this class was generated from the following files:
Generated on Thu Mar 11 21:57:52 2004 for Music Playing Daemon client by doxygen1.2.15