Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A node.js client for MPD

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .npmignore
Octocat-spinner-32 COPYING
Octocat-spinner-32 README.md
Octocat-spinner-32 mpdsocket.js
Octocat-spinner-32 package.json
README.md

node-mpdsocket

mpdsocket is a node.js client for MPD. It is loosely based on (but aims to be more usable than) robinduckett/node-mpd.

Usage

Example

var mpdSocket = require('mpdsocket');
var mpd = new mpdSocket('localhost','6600');

mpd.on('connect',function() {
    mpd.send('status',function(r) {
        console.log(r);
    });
});

Functions

  • mpdSocket.on(event,fn) adds event handlers to the net.Socket object directly.
  • mpdSocket.send(req,callback) sends a request to MPD with a callback function.

Return objects

mpdsocket parses the output from the MPD protocol into a JavaScript object. This object has three meta-attributes that mpdsocket adds:

  • _OK denotes that the request was completed successfully.
  • _error is the error returned if _OK is false.
  • _ordered_list denotes that the object is an ordered list (see section below).

Ordered lists

Some MPD commands, like listplaylists, will return an ordered list of objects. The structure of these objects looks like this:

{ '1':
    { playlist: 'playlist-1',
      'Last-Modified': '2011-03-19T06:39:44Z' },
  '2':
    { playlist: 'playlist-2',
      'Last-Modified': '2011-03-19T06:41:08Z' },
  _ordered_list: true,
  _OK: true
}

License

node-mpdsocket is made available under the MIT License. A copy of the license is distributed with this software.

Copyright (c) 2011 Eli Wenig

Something went wrong with that request. Please try again.