You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rainer Hihn 31d95c913e M src/main/java/org/bff/javampd/server/ 10 months ago
.github Create dependabot.yml 10 months ago
src M src/main/java/org/bff/javampd/server/ 10 months ago
.gitignore init 10 months ago
LICENSE.txt init 10 months ago Update 10 months ago
pom.xml Set license to GPL2 (according to LICENSE.txt) 10 months ago


This is a fork of finnyb/javampd

JavaMPD is used by java clients to control the cool MPD.






Create a connection to MPD using the builder.

Using default values of localhost port 6600

MPD mpd = new MPD.Builder().build();

or build to your environment

MPD mpd = new MPD.Builder()

Almost everything you'll need will be gotten from this object.

The connection remains open for the life of the MPD object so take care not to create new MPD objects each time you want to do something. Call close on the object when you are done.


When running on the same server as MPD a list of artwork can be obtained for an artist or album. If not running on the same server but hosting the images locally a path prefix can be passed to locate the images.

A list of all images in the directory can be returned if those files are readable by whatever user is running JavaMPD.

Ideally you should have some directory structure like /Artist/Album/song.flac /Artist/Album/cover.jpg

When searching for artist images assumptions are made that the artist lives in her own directory. Images in the artist directory are returned first then images for each album are returned.

supported image types: jpg and png

ArtworkFinder artworkFinder = mpd.getArtworkFinder();
List<MPDArtwork> artworkList = artworkFinder.find(album);


Searching for songs is done via the SongSearcher class.



MPD database access is accomplished using the appropriate access object from the MPDMusicDatabase.

Get the database from MPD.


There is a database for the following:

  • Songs
  • Albums
  • Artists
  • Genres
  • Years
  • Playlists
  • Files


slf4j is used for logging allowing you to use any compatible logging framework. The following examples use logback.

Lots of debugging information can be obtained from debug level logging.

<root level="debug">
    <appender-ref ref="STDOUT"/>


MPDStandAloneMonitor to monitor events

Refresh Intervals

The monitor.delay property is the length of time (in seconds) that the monitor sleeps between rounds. Each monitor has a multiplier that can be overridden depending on the desired check frequency. Setting the multiplier value to 0 means checking every time the monitor runs (0 based).

The following properties can be overridden:



To override place a file on the classpath with your desired overrides:

For example:


would check for playlist changes every ~5 seconds

or maybe something list this:


would run the monitor every ~10 seconds checking the playlist every ~10 seconds and the track every ~30

Server status

load the server status by getting the status from MPD.

ServerStatus status = mpd.getServerStatus();
int volume = status.getVolume();

There is a default expiry interval of 5 seconds. This can be overridden by setting the interval using setExpiryInterval, use 0 to always call the server for each method.

ServerStatus status = mpd.getServerStatus();
//removes 5 second cache

Status updates can be force using forceUpdate

ServerStatus status = mpd.getServerStatus();
//reset the update clock so updates are pulled

Server statistics

load the server statistics by getting the status from MPD.

ServerStatistics stats = mpd.getServerStatistics();
long uptime = status.getUptime();

It has an default expiry interval of 60 seconds. Caching behavior is exactly like the status.