Giter Club home page Giter Club logo

mpd.js's Introduction

node mpd client

Connect to a music player daemon server, send commands, emit events.

You might also be interested in checking out node-groove, a generic music player backend as a node module.

Or maybe Groove Basin, a music player server which supports the MPD protocol and has many features and improvements over MPD.

Usage

var mpd = require('mpd'),
    cmd = mpd.cmd
var client = mpd.connect({
  port: 6600,
  host: 'localhost',
});
client.on('ready', function() {
  console.log("ready");
});
client.on('system', function(name) {
  console.log("update", name);
});
client.on('system-player', function() {
  client.sendCommand(cmd("status", []), function(err, msg) {
    if (err) throw err;
    console.log(msg);
  });
});

Documentation

See also the MPD Protocol Documentation.

Functions

mpd.cmd(name, args)

Convert name/args pair into a Command.

mpd.connect(options)

Connects and returns a client.

mpd.parseKeyValueMessage(msg)

msg: a string which contains an MPD response. Returns an object.

client.sendCommand(command, callback)

command can be a MpdClient.Command or a string.

client.sendCommands(commandList, callback)

Events

error(err)

end

The connection is closed.

connect

A socket connection has been made.

ready

The mpd server is ready to accept commands.

system(systemName)

A system has updated. systemName is one of:

  • database - the song database has been modified after update.
  • update - a database update has started or finished. If the database was modified during the update, the database event is also emitted.
  • stored_playlist - a stored playlist has been modified, renamed, created or deleted
  • playlist - the current playlist has been modified
  • player - the player has been started, stopped or seeked
  • mixer - the volume has been changed
  • output - an audio output has been enabled or disabled
  • options - options like repeat, random, crossfade, replay gain
  • sticker - the sticker database has been modified.
  • subscription - a client has subscribed or unsubscribed to a channel
  • message - a message was received on a channel this client is subscribed to; this event is only emitted when the queue is empty

system-*

See above event. Each system name has its own event as well.

mpd.js's People

Contributors

andrewrk avatar thejoshwolfe avatar nmunro avatar sweetpi avatar adamvr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.