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) {
|
function wsSend(obj) {
|
||||||
ws.send(JSON.stringify(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) {
|
function handleMessage(msg) {
|
||||||
switch (msg.event) {
|
switch (msg.event) {
|
||||||
case "state": {
|
case "state": {
|
||||||
const d = msg.data || {};
|
const d = msg.data || {};
|
||||||
if(d.dirs) updateDirs(d.dirs);
|
if(d.dirs) updateDirs(d.dirs);
|
||||||
if(d.track) applyProgressState(d.track);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case "rds":
|
case "rds":
|
||||||
@@ -124,11 +102,9 @@ function handleMessage(msg) {
|
|||||||
break;
|
break;
|
||||||
case "new_track":
|
case "new_track":
|
||||||
applyTrackState(msg.data);
|
applyTrackState(msg.data);
|
||||||
if(pollLockHeld) {
|
wsSend({ action: "get_toplay" });
|
||||||
wsSend({ action: "get_toplay" });
|
wsSend({ action: "skipc" });
|
||||||
wsSend({ action: "skipc" });
|
wsSend({ action: "skipi" });
|
||||||
wsSend({ action: "skipi" });
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "progress":
|
case "progress":
|
||||||
applyProgressState(msg.data);
|
applyProgressState(msg.data);
|
||||||
|
|||||||
Reference in New Issue
Block a user