-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.js
52 lines (42 loc) · 1.48 KB
/
lib.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use strict";
let SVCNAME = "com.roonlabs.audioinput:1";
/**
* Roon API Audio Input Service
* @class RoonApiAudioInput
* @param {Core} core - The Core providing the service
*/
function RoonApiAudioInput(core) {
this.core = core;
}
RoonApiAudioInput.services = [ { name: SVCNAME } ];
RoonApiAudioInput.prototype.begin_session = function(options, cb) {
const moo = this.core.moo;
let ret = {
session_id: null,
end_session(cb) {
if (this.session_id)
moo.send_request(SVCNAME + "/end_session", { session_id: this.session_id }, cb);
}
};
this.core.moo.send_request(SVCNAME + "/begin_session", options,
function (msg, body) {
if (!msg) return;
if (msg.name == "SessionBegan")
ret.session_id = body.session_id;
cb(msg.name, body);
});
return ret;
};
RoonApiAudioInput.prototype.play = function(options, cb) {
this.core.moo.send_request(SVCNAME + "/play", options, cb);
};
RoonApiAudioInput.prototype.clear = function(options, cb) {
this.core.moo.send_request(SVCNAME + "/clear", options, cb);
};
RoonApiAudioInput.prototype.update_track_info = function(options, cb) {
this.core.moo.send_request(SVCNAME + "/update_track_info", options, cb);
};
RoonApiAudioInput.prototype.update_transport_controls = function(options, cb) {
this.core.moo.send_request(SVCNAME + "/update_transport_controls", options, cb);
};
module.exports = RoonApiAudioInput;