From 7505bc28d3df6598921661c50d68ca49b6c62f98 Mon Sep 17 00:00:00 2001 From: Kristy Fournier <124598538+kristy-fournier@users.noreply.github.com> Date: Thu, 6 Mar 2025 10:45:51 -0500 Subject: [PATCH] Volume cannot be changed when player isn't playing --- Client/scripts.js | 9 +++++++-- Client/styles.css | 4 ++-- Server/webbyBits.py | 24 ++++++++++++++---------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Client/scripts.js b/Client/scripts.js index 2aa73c7..bf0f463 100644 --- a/Client/scripts.js +++ b/Client/scripts.js @@ -170,6 +170,7 @@ function ipSetter(){ async function checkSettings(skipServer=false) { //check client stuff first so if the server doesn't exist it can still be changed and seen if (ip.slice(-5)=="19054") { + // don't show the port if it is the default document.getElementById("iptextbox").value = ip.slice(0,-6) } else { document.getElementById("iptextbox").value = ip; @@ -309,8 +310,12 @@ document.getElementById("playlist-mode").style.display = "none"; document.getElementById("settings-mode").style.display = "none"; //.ontouch for mobile?? document.getElementById("volumerange").onchange = function() { - getFromServer({setting:"volume",level:this.value}, "settings") - if (this.value == 0) { + let returnValue = getFromServer({setting:"volume",level:this.value}, "settings") + if (returnValue !=0) { + alertText("Nothing is playing") + document.getElementById("volumerange").value = -1 + } + else if (this.value == 0) { alertText("The volume is now set to 0 (Pause?)") } else { alertText("The volume is now set to " + this.value.toString()) diff --git a/Client/styles.css b/Client/styles.css index 59ac410..bfcd94d 100644 --- a/Client/styles.css +++ b/Client/styles.css @@ -74,7 +74,7 @@ h4 { /* Songlist stuff */ .songlist { - width: 70%; + width: 80%; min-width: 300px; margin:auto auto 150px; display: flex; @@ -86,7 +86,7 @@ h4 { width:30%; max-width: 150px; margin: 5px auto; - min-width: 100px; + min-width: 75px; background-color: inherit; } diff --git a/Server/webbyBits.py b/Server/webbyBits.py index d645bb2..3251649 100644 --- a/Server/webbyBits.py +++ b/Server/webbyBits.py @@ -97,10 +97,11 @@ def playerControls(): def settingsControl(): # set the volume and partymode global partyMode + global player recieveData = request.get_json(force=True) if recieveData["setting"] == "volume": - player.audio_set_volume(int(recieveData["level"])) - return "200" + volumePassed = player.audio_set_volume(int(recieveData["level"])) + return {"volumePassed":volumePassed} elif recieveData["setting"] == "partymode-toggle": partyMode = not(partyMode) return "200" @@ -117,15 +118,18 @@ def searchSongDB(): # the way i put the data in a list was really dumb looking back, i could and should have used a list of dictioaries like i was before # i might try to change it but this layout is embedded deep in the client tempData = {} - for i in songDatabaseList["songData"]: - if ((songDatabaseList["songData"][i]["title"].lower().find(recieveData['search'].lower())) > -1) or (recieveData['search'] == ""): - tempData[i] = songDatabaseList["songData"][i] - - try: - if (songDatabaseList["songData"][i]["artist"].lower().find(recieveData['search'].lower()) > -1): + if (recieveData['search'] == ""): + tempData = songDatabaseList["songData"].copy() + else: + for i in songDatabaseList["songData"]: + if ((songDatabaseList["songData"][i]["title"].lower().find(recieveData['search'].lower())) > -1): tempData[i] = songDatabaseList["songData"][i] - except: - pass + + try: + if (songDatabaseList["songData"][i]["artist"].lower().find(recieveData['search'].lower()) > -1): + tempData[i] = songDatabaseList["songData"][i] + except: + pass # print(tempData) return tempData