0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-26 21:53:54 +01:00

jingel top

This commit is contained in:
2025-12-27 22:25:27 +01:00
parent 5a96f58ec4
commit a036786140
3 changed files with 10 additions and 5 deletions

View File

@@ -43,11 +43,11 @@ class Module2(PlayerModule):
def imc(self, imc: InterModuleCommunication) -> None:
super().imc(imc)
self._imc.register(self, "jingle")
def imc_data(self, source: BaseIMCModule, source_name: str | None, data: object, broadcast: bool) -> object:
def imc_data(self, source: BaseIMCModule, source_name: str | None, data: bool, broadcast: bool) -> object:
if broadcast: return
jingle = self.primary
if self.secondary and (random.randint(1,3) == 1): jingle = random.choice(self.secondary)
return self._imc.send(self, "activemod", {"action": "add_to_toplay", "songs": [f"!{jingle}"]})
return self._imc.send(self, "activemod", {"action": "add_to_toplay", "songs": [f"!{jingle}"], "top": bool(data)})
options = Path("/home/user/Jingiel.mp3"), [Path("/home/user/jing2.opus"), Path("Jing3.opus")]
module = Module2(*options)

View File

@@ -81,6 +81,7 @@
<button id="clear-btn" class="btn">✖ Clear the Queue</button>
<button id="skpn-btn" class="btn">⏭? Toggle skip next</button>
<button id="jingle-btn" class="btn">🕭 Add Jingle</button>
<button id="jingle2-btn" class="btn">🕭 Add Jingle (prepend)</button>
</div>
</div>
@@ -417,6 +418,10 @@
if(ws && ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({action:"jingle"}));
else console.error("WebSocket not connected.");
});
document.getElementById("jingle2-btn").addEventListener("click", () => {
if(ws && ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({action:"jingle", top: true}));
else console.error("WebSocket not connected.");
});
document.getElementById("clear-btn").addEventListener("click", () => {ws.send(JSON.stringify({action:"clear_toplay"}))});
@@ -470,12 +475,12 @@
if (e.target.tagName === "INPUT") return;
if (e.key === "Enter") {
const added = addSelectedFileToQueue(false);
const added = addSelectedFileToQueue(e.shiftKey);
if (added) e.preventDefault();
}
if (e.key === "s") ws.send(JSON.stringify({action:"skip"}));
if (e.key === "n") ws.send(JSON.stringify({action:"skip_next"}));
if (e.key === "j") ws.send(JSON.stringify({action:"jingle"}));
if (e.key === "j") ws.send(JSON.stringify({action:"jingle", top: e.shiftKey}));
});
setTimeout(connectWs, 100)

View File

@@ -69,7 +69,7 @@ async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: mult
if result is None: await websocket.send(json.dumps({"error": "timeout", "code": 504}))
else: await websocket.send(json.dumps({"data": result, "event": "skip_next"}))
elif action == "jingle":
result = await get_imc("jingle", None)
result = await get_imc("jingle", msg.get("top", False))
if result is None: await websocket.send(json.dumps({"error": "timeout", "code": 504}))
else:
await websocket.send(json.dumps(result))