Upcoming Promise-based MPD client for NodeJS.
$ npm i
Alternate variant via yarn:
$ yarn install
$ npm run build
// Import MPDClient.js module.
const mpdclient = require('mpdclient.js');
// Create connection with MPD server.
const client = new mpdclient.MPDClient('localhost', 6600);
// Create command.
const command = new mpdclient.MPDCommand('status');
// Or you can create chain of commands.
const commands = [
new mpdclient.MPDCommand('play'),
new mpdclient.MPDCommand('status')
];
// You can pass the mode for eval command list.
const commandList = new mpdclient.MPDCommandList(commands, mpdclient.MPDCommandList.COMMAND_LIST_OK_BEGIN);
// As MPDClient.js provides Promise-based API it means
// that there are 2 callbacks for handle execution result:
client.execute(command).then(
response => {
// Handle parsed response object.
},
error => {
// Handle error.
}
);
const mpdclient = require('mpdclient.js');
const client = new mpdclient.MPDClient('localhost', 6600);
const command = new mpdclient.MPDCommand('status');
client.execute(command)
.then(response => console.log(response))
.catch(error => console.log(error));