-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlers.js
53 lines (39 loc) · 1.09 KB
/
handlers.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
52
'use strict';
var util = require('./util');
function handlePlay(req, resp){
util.play(req, resp,0,0,"REPLACE_ALL");
}
function handleResume(req, resp) {
var deviceId = req.data.context.System.device.deviceId;
var idx = util.getIndex(deviceId);
if(!idx) idx=0;
var offset = util.getOffset(deviceId);
if(!offset) offset = 0;
util.play(req, resp, idx, offset, "REPLACE_ALL");
}
function handleStop(req, resp) {
resp.audioPlayerStop();
}
function handleLoopOff(req, resp) {
}
function handleLoopOn(req, resp) {
}
function handleNext(req, resp) {
var i = util.getNext(req.data.context.System.device.deviceId);
if(!i) i = 0;
util.play(req, resp, i,0,"REPLACE_ALL");
}
function handlePrevious(req, resp) {
var i = util.getPrevious(req.data.context.System.device.deviceId);
if(!i) i = 0;
util.play(req, resp, i,0,"REPLACE_ALL");
}
module.exports = {
handleNext : handleNext,
handlePrevious : handlePrevious,
handleLoopOff : handleLoopOff,
handleLoopOn : handleLoopOn,
handlePlay : handlePlay,
handleResume : handleResume,
handleStop : handleStop
}