blob: e1a56032da6de2ebe592f553728ade0c68d998df (
plain) (
blame)
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
|
window.onload=function() {
soundManager.setup({
url: "/swf/",
preferFlash: false,
onready: function() {
window.soundPlayer = soundManager.createSound({
id: 'radio',
url: 'http://91.121.59.45:8089/stream',
stream: true,
autoPlay: false,
usePolicyFile: true,
preferFlash: false,
autoStart: false
})
var playButton = document.getElementById("state");
playButton.onclick = function() {
if (window.playerPlaying) {
console.log("should stop")
window.soundPlayer.stop();
window.playerPlaying = false;
playButton.innerHTML = "▶";
} else {
console.log("should start");
window.soundPlayer.start();
window.playerPlaying = true;
playButton.innerHTML = "⏸";
}
}
},
ontimeout: function() {
console.log("soundmanager timeout")
}
});
window.evtSource = new EventSource("/api/icecast.sse");
window.icecastStats = {};
window.evtSource.addEventListener('icecast', function(e) {
var data = JSON.parse(e.data).icecast;
document.getElementById("np").innerHTML = data.np;
document.getElementById("genre").innerHTML = data.genre + " <span>en direct</span>";
player = document.getElementById("player");
if (data.live != window.icecastStats.live) {
if (data.live) {
player.classList = ["live"];
console.log("is live");
} else {
player.classList = ["autodj"];
console.log("stopped live");
}
}
window.icecastStats = data;
}, false);
}
|