0.0.21 • Published 6 years ago
mpdclient.js v0.0.21
mpdclient.js
Upcoming Promise-based MPD client for NodeJS.
Init
$ npm i
Alternate variant via yarn:
$ yarn install
Build
$ npm run build
Usage
Import module:
// Import MPDClient.js module.
const mpdclient = require('mpdclient.js');
Create connection with MPD server:
// Create connection with MPD server.
const client = new mpdclient.MPDClient('localhost', 6600);
Prepare command (or command list) for execute:
// 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);
Execute command or command list:
// 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.
}
);
Completed example
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));
0.0.21
6 years ago
0.0.20
6 years ago
0.0.19
6 years ago
0.0.18
7 years ago
0.0.17
7 years ago
0.0.16
7 years ago
0.0.15
7 years ago
0.0.14
7 years ago
0.0.13
7 years ago
0.0.11
7 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago
1.0.0
7 years ago