-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.js
58 lines (47 loc) · 1.14 KB
/
start.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
const nodaryEncoder = require('nodary-encoder');
const myEncoder = nodaryEncoder(20, 9);
let previousStation = 0
let station = 0
let rotationValue = 0
const stationsTitles = [
'Vaporwaves',
'Boot Liquor',
'Indie Pop Rocks',
'Groove Salad',
'Underground 80s',
'Seven Inch Soul',
'Lush',
]
const stations = [
'http://somafm.com/m3u/vaporwaves.m3u',
'http://somafm.com/m3u/bootliquor.m3u',
'http://somafm.com/m3u/indiepop.m3u',
'http://somafm.com/m3u/groovesalad.m3u',
'http://somafm.com/m3u/u80s.m3u',
'http://somafm.com/m3u/7soul.m3u',
'http://somafm.com/m3u/lush.m3u',
]
myEncoder.on('rotation', (direction, value) => {
previousStation = station
if (value > stations.length - 1) {
station = stations.length - 1
} else if (value < 0) {
station = 0
} else {
station = value
}
rotationValue = value
if (station !== previousStation) {
console.log(stationsTitles[station])
player.openPlaylist(stations[station], {
cache: 128,
cacheMin: 1
})
}
});
const MPlayer = require('mplayer');
const player = new MPlayer();
player.openPlaylist(stations[station], {
cache: 128,
cacheMin: 1
})