-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
44 lines (37 loc) · 1.28 KB
/
app.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
// playBtn
const playPauseBtn = document.querySelector('#startAudioContext');
playPauseBtn.addEventListener('click', () => {
// play or pause track depending on state
if (playPauseBtn.dataset.playing === 'false') {
ediPlayer.start({url:'https://bredi.irt.de:443/services/13'})
playPauseBtn.dataset.playing = 'true';
playPauseBtn.firstChild.innerHTML = 'access_time';
} else if (playPauseBtn.dataset.playing === 'true') {
ediPlayer.stop();
playPauseBtn.dataset.playing = 'false';
playPauseBtn.firstChild.innerHTML = 'access_time';
}
} , false);
ediPlayer.addEventListener('stateChange', (state) => {
switch (state) {
case 'running':
playPauseBtn.firstChild.innerHTML = 'stop';
break;
case 'stopped':
playPauseBtn.firstChild.innerHTML = 'play_arrow';
break;
}
});
const prettyPrintJson = (json) => {
M.toast({html: '<pre>' + JSON.stringify(json, null, 10) + '</pre>'});
}
ediPlayer.addEventListener('sls', (obj) => {
M.toast({html: '<img src="' + obj.url + '">'});
prettyPrintJson(obj);
});
ediPlayer.addEventListener('msg', (obj) => {
prettyPrintJson(obj);
});
ediPlayer.addEventListener('dls', (obj) => {
prettyPrintJson(obj);
});