mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-07-29 15:29:14 +02:00
great
This commit is contained in:
+3
-27
@@ -85,34 +85,12 @@ function connectWs() {
|
||||
function wsSend(obj) {
|
||||
ws.send(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
function gotLock() {
|
||||
setTimeout(() => {
|
||||
wsSend({action: "lock", "id": 0});
|
||||
wsSend({action: "get_toplay"});
|
||||
wsSend({action: "skipc"});
|
||||
wsSend({action: "skipi"});
|
||||
pollLockHeld = true;
|
||||
}, 500 + (Math.random() * 2500))
|
||||
}
|
||||
|
||||
function handleLockState(msg) {
|
||||
if(msg[0] == true) pollLockHeld = false;
|
||||
else gotLock();
|
||||
}
|
||||
|
||||
function handleMessage(msg) {
|
||||
switch (msg.event) {
|
||||
case "state": {
|
||||
const d = msg.data || {};
|
||||
if(d.dirs) updateDirs(d.dirs);
|
||||
if(d.track) applyProgressState(d.track);
|
||||
if(d.locks) handleLockState(d.locks)
|
||||
break;
|
||||
}
|
||||
case "lock": {
|
||||
if(msg.error) pollLockHeld = false;
|
||||
else if (msg.id == 0 && msg.data == false) gotLock();
|
||||
break;
|
||||
}
|
||||
case "rds":
|
||||
@@ -124,11 +102,9 @@ function handleMessage(msg) {
|
||||
break;
|
||||
case "new_track":
|
||||
applyTrackState(msg.data);
|
||||
if(pollLockHeld) {
|
||||
wsSend({ action: "get_toplay" });
|
||||
wsSend({ action: "skipc" });
|
||||
wsSend({ action: "skipi" });
|
||||
}
|
||||
wsSend({ action: "get_toplay" });
|
||||
wsSend({ action: "skipc" });
|
||||
wsSend({ action: "skipi" });
|
||||
break;
|
||||
case "progress":
|
||||
applyProgressState(msg.data);
|
||||
|
||||
Reference in New Issue
Block a user