-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_helper.js
78 lines (59 loc) · 1.63 KB
/
node_helper.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const NodeHelper = require('node_helper');
const SpotifyConnector = require('./core/SpotifyConnector');
module.exports = NodeHelper.create({
start: function () {
this.connector = undefined;
},
socketNotificationReceived: function (notification, payload) {
switch (notification) {
case 'CONNECT_TO_SPOTIFY':
this.connector = new SpotifyConnector(payload);
break;
case 'UPDATE_CURRENT_SONG':
break;
case 'PLAY_SPOTIFY':
this.connector.playThis(payload).catch((error) => {
console.error('Can’t start playing. Reason: ');
console.error(error);
});
break;
case 'PLAY_NEXT_SPOTIFY':
this.connector.NextSpotify(payload).catch((error) => {
console.error('Can’t change song. Reason: ');
console.error(error);
});
break;
case 'PLAY_PREVIOUS_SPOTIFY':
this.connector.PreviousSpotify(payload).catch((error) => {
console.error('Can’t change song. Reason: ');
console.error(error);
});
break;
case 'PAUSE_SPOTIFY':
this.connector.PauseSpotify(payload).catch((error) => {
console.error('Can’t pause player. Reason: ');
console.error(error);
});
break;
case 'RESUME_SPOTIFY':
this.connector.ResumeSpotify(payload).catch((error) => {
console.error('Can’t resume player. Reason: ');
console.error(error);
});
break;
case 'SHUFFLE':
//todo
break;
case 'REPEAT':
//todo
break;
case 'SEEK':
//todo
break;
case 'SET_VOLUME':
//todo
break;
}
},
});