optimized network calls
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,4 @@
|
||||
import stat
|
||||
import requests
|
||||
|
||||
class ServerComs:
|
||||
@@ -47,7 +48,6 @@ class ServerComs:
|
||||
return False
|
||||
|
||||
def getfullscreeninfo(self, url):
|
||||
print("fullscreencheck")
|
||||
try:
|
||||
self.x = requests.get(f"{url}/fullscreen")
|
||||
return self.x.text
|
||||
@@ -55,10 +55,16 @@ class ServerComs:
|
||||
print(e)
|
||||
return "False"
|
||||
|
||||
def poststatus(self, url, isalive):
|
||||
print("updating status")
|
||||
def poststatus(self, url, statuscode):
|
||||
try:
|
||||
self.x = requests.post(f"{url}/poststatus", {"status":f"{isalive}"})
|
||||
self.x = requests.post(f"{url}/poststatus", {"status":statuscode})
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def requestUIupdate(self, url):
|
||||
try:
|
||||
self.x = requests.get(f"{url}/requestuiupdate")
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
3
|
||||
4
|
||||
Tennessee Waltz - New 101 Strings Orchestra | Slow Walz (Langsam),Morning has broken - Cat Stevens | Walzer (Mittel),Magia - Alvaro Soler | Flashmob (Mittel),Say So - Doja Cat | Discofox (Langsam),Save Your Tears (Remix) - The Weeknd & Ariana Grande | Discofox (Langsam),Shivers - Ed Sheeran | Jive/ Rocknroll (Mittel),I feel good - Ray Charles | Jive/Rocknroll (Mittel),Muevelo - Rey Ruiz | Cha cha cha (Mittel),Suelta la cintura - Ruben leon | Cha cha cha (Mittel),Como Volver a Ser Feliz - Luis Enrique | Salsa (Mittel),Mas que nada - black eyed peas | Salsa/Discofox (Mittel),Moon River - Henry Mancini | Slow Walz (Langsam),Dancing Queen - ABBA | Discofox (Langsam),Don't Call Me Up - Mabel | Discofox (Mittel),Magia - Alvaro Soler | Flashmob (Mittel),Lets have a Party - Wanda Jackson | Jive (mittel),Crazy Little Thing Called Love - Queen | Jive / Rocknroll (Schnell),El Diablo Anda Suelto - Rey Ruiz | Cha cha cha (Mittel),Lets get loud - Jennifer Lopez | Cha cha cha (Schnell),Enamorame - Somos del Barrio | Salsa (Mittel),Something Stupid (feat. Reese Witherspoon) - Michael Bublé | Rumba/cha cha cha (Langsam),When a man loves a woman - Percy Sledge | (Langsam),Scharlachrot - Patent Ochsner | Walzer (Langsam),Ily (i love you baby) [feat. Emilee] - Surf Mesa | Discofox (Mittel),Like a sex machine - James Brown | Discofox (Mittel),Uptown Funk (feat. Bruno Mars) - Discofox | Discofox (Schnell),Tutti Frutti - Little Richard | Jive / Rocknroll (Mittel),Jailhouse Rock - Elvis Presley | Jive / Rocknroll (Schnell),Are you lonesome - Elvis Presley | Slow Walz (Langsam),Ay Mujer - Rey Ruiz | Cha cha cha (Mittel),Rico Vacilon - Pedro Garcia & His Del Prado Orchestra | Cha cha cha (Mittel),Jeepers creepers - Benny Goodmann | Foxtrott (Mittel),An der schönen blauen Donau - New 101 Strings Orchestra | Wiener Walzer (Schnell),The Last Waltz - Engelbert Humperdinck | Walzer (Mittel),Stand by me - Sam Brown | Cha cha cha (Lansam),Stayin' Alive - Bee Gees | Discofox (Mittel),Easy On Me - Adele | (Langsam),Magia - Alvaro Soler | Flashmob (Mittel),Friday (feat. Mufasa & Hypeman) [Dopamine Re-Edit] - Riton & Nightcrawlers | Party (Mittel),YMCA - Village People | Party (Mittel),Cotton eyed Joe (Hennustall zermatt mix) - Rednex | Party (Mittel),Gangnam style - PSY | Party (Mittel),Take On Me - a-ha | Jive (Schnell),Rock Around the Clock - Bill Haley & His Comets | Jive / Rocknroll (Schnell),Satisfaction - Rolling Stones | Party (Mittel),"Un, dos, tres - Ricky Martin | Party (Mittel)",Party Rock anthem - LFMBQ | Party (Mittel),I don't care - Icona Pop | Party (Mittel),Love tonight - Shouse & David Guetta | Party (Mittel),Insomnia - Faithless | Party (Mittel),Angels - Robbie Williams | Slow (Langsam),Nothing compares to you - Sinead O'Connor | Slow (Langsam)
|
||||
237.88844299316406
|
||||
191.00733947753906
|
||||
|
||||
|
@@ -81,7 +81,7 @@ class ConnectPU(Popup):
|
||||
|
||||
class QuitPU(Popup):
|
||||
def quitapp(self):
|
||||
svc.poststatus(address, False)
|
||||
svc.poststatus(address, "stopped")
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
@@ -192,6 +192,7 @@ class Main(MDScreen):
|
||||
self.keyboard.bind(on_key_down=self.key_pressed)
|
||||
self.quit_requests = 0
|
||||
self.__comparepos = 10000
|
||||
self.__updateui = False
|
||||
global address
|
||||
|
||||
def key_pressed(self, keyboard, keycode, text, modifiers):
|
||||
@@ -226,7 +227,7 @@ class Main(MDScreen):
|
||||
self.__comparepos = 10000
|
||||
if address != "":
|
||||
self.ids.connectstatus.text = f"Connected to: {address}"
|
||||
svc.poststatus(address, True)
|
||||
svc.poststatus(address, "paused")
|
||||
if svc.getfullscreeninfo(address) == "True":
|
||||
self.ids.fullscreenc.text = "Exit fullscreen on client display"
|
||||
else:
|
||||
@@ -261,21 +262,27 @@ class Main(MDScreen):
|
||||
self.mplayer.start()
|
||||
|
||||
def playmusic(self):
|
||||
self.updateremoteUI()
|
||||
self.others.value = 3
|
||||
if self.instructions.value == 0:
|
||||
svc.poststatus(address, "playing")
|
||||
self.instructions.value = 1
|
||||
self.ids.pp_button.text = "Pause"
|
||||
else:
|
||||
svc.poststatus(address, "paused")
|
||||
self.instructions.value = 0
|
||||
self.ids.pp_button.text = "Play"
|
||||
|
||||
def nextsong(self):
|
||||
self.updateremoteUI()
|
||||
self.others.value = 1
|
||||
|
||||
def rewindsong(self):
|
||||
self.updateremoteUI()
|
||||
self.others.value = 2
|
||||
|
||||
def previoussong(self):
|
||||
self.updateremoteUI()
|
||||
self.others.value = 4
|
||||
|
||||
def go_back(self):
|
||||
@@ -283,7 +290,7 @@ class Main(MDScreen):
|
||||
self.mplayer.kill()
|
||||
except:
|
||||
pass
|
||||
svc.poststatus(address, False)
|
||||
svc.poststatus(address, "stopped")
|
||||
self.ids.pp_button.text = "Play"
|
||||
self.manager.current = "Home"
|
||||
self.manager.transition.direction = "right"
|
||||
@@ -338,12 +345,12 @@ class Main(MDScreen):
|
||||
self.__length_output += 1
|
||||
self.manager.get_screen("Showcase").ids.upcoming_songs.text = self.__upcoming_output
|
||||
if address != "":
|
||||
svc.postplaybackpos(address, self.__songpos)
|
||||
if self.__comparepos > self.__songpos:
|
||||
if self.__comparepos > self.__songpos or self.__updateui:
|
||||
svc.postplaybackpos(address, self.__songpos)
|
||||
svc.postcurrentsong(address, self.__current_output)
|
||||
svc.postsonglength(address, self.__songlength)
|
||||
svc.postupcomingsongs(address, self.__upcoming_output)
|
||||
# svc.postfullscreen(address, self.__current_output)
|
||||
self.__updateui = False
|
||||
else:
|
||||
pass
|
||||
self.__comparepos = self.__songpos
|
||||
@@ -359,6 +366,10 @@ class Main(MDScreen):
|
||||
else:
|
||||
pass
|
||||
|
||||
def updateremoteUI(self):
|
||||
self.__updateui = True
|
||||
svc.requestUIupdate(address)
|
||||
|
||||
def open_leave_popup(self):
|
||||
LeavePU().open()
|
||||
|
||||
@@ -403,7 +414,7 @@ class MusicPlayer(MDApp):
|
||||
global address
|
||||
AppQuitting().open()
|
||||
print("leaving...")
|
||||
svc.poststatus(address, False)
|
||||
svc.poststatus(address, "stopped")
|
||||
time.sleep(1)
|
||||
os.killpg(os.getpgid(0), signal.SIGKILL)
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ var upcomingsongs = "Test\nTest2\nTest3"
|
||||
var currentsong = "This is a song"
|
||||
var songmaxlength = "100"
|
||||
var fullscreen = "False"
|
||||
var isrunning = "False"
|
||||
var status = "n/a"
|
||||
var doupdateUI = "False"
|
||||
var isplaying = "False"
|
||||
|
||||
|
||||
// CONFIG FOR EXPRESS
|
||||
@@ -50,29 +52,40 @@ app.get('/currentsong', (request, response) => {
|
||||
})
|
||||
|
||||
app.get('/fullscreen', (request, response) => {
|
||||
console.log("getting fullscreen status")
|
||||
response.send(fullscreen)
|
||||
})
|
||||
|
||||
app.get('/isrunning', (request, response) => {
|
||||
response.send(isrunning)
|
||||
response.send(status)
|
||||
})
|
||||
|
||||
app.get('/uiupdate', (request, response) => {
|
||||
response.send(doupdateUI)
|
||||
doupdateUI = "False"
|
||||
})
|
||||
|
||||
app.get('/isplaying', (request, response) => {
|
||||
response.send(isplaying)
|
||||
})
|
||||
|
||||
|
||||
|
||||
// POST data (Interface for Player)
|
||||
app.post('/postplayback', (request, response) => {
|
||||
playbackpos = request.body.pos
|
||||
doupdateUI = "True"
|
||||
response.send("ok")
|
||||
})
|
||||
|
||||
app.post('/postupcomingsongs', (request, response) => {
|
||||
console.log("updating upcomingsongs")
|
||||
upcomingsongs = request.body.songs
|
||||
doupdateUI = "True"
|
||||
response.send("ok")
|
||||
})
|
||||
|
||||
app.post('/postcurrentsong', (request, response) => {
|
||||
currentsong = request.body.songname
|
||||
doupdateUI = "True"
|
||||
response.send("ok")
|
||||
})
|
||||
|
||||
@@ -88,12 +101,19 @@ app.get('/changefullscreen', (request, response) => {
|
||||
|
||||
app.post('/postsonglength', (request, response) => {
|
||||
songmaxlength = request.body.length
|
||||
console.log(songmaxlength)
|
||||
doupdateUI = "True"
|
||||
response.send("ok")
|
||||
})
|
||||
|
||||
app.post('/poststatus', (request, response) => {
|
||||
console.log("updating status " + request.body.status)
|
||||
isrunning = request.body.status
|
||||
status = request.body.status
|
||||
doupdateUI = "True"
|
||||
response.send("ok")
|
||||
})
|
||||
|
||||
app.get('/requestuiupdate', (request, response) => {
|
||||
doupdateUI = "True"
|
||||
response.send("ok")
|
||||
})
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -63,6 +63,13 @@ class Com:
|
||||
self.x = requests.get(f"{url}/isrunning")
|
||||
except Exception:
|
||||
return False
|
||||
return self.x.text
|
||||
|
||||
def getuiupdate(self, url):
|
||||
try:
|
||||
self.x = requests.get(f"{url}/uiupdate")
|
||||
except Exception:
|
||||
return False
|
||||
if self.x.text == "True":
|
||||
return True
|
||||
else:
|
||||
|
||||
@@ -57,11 +57,24 @@ class ShowcaseScreen(MDScreen):
|
||||
self.__upcoming = comHandler.getupcomingsongs(address)
|
||||
self.songlength = comHandler.getsonglength(address)
|
||||
self.songpos = comHandler.getsongpos(address)
|
||||
self.ids.current_song.text = self.__current
|
||||
self.ids.upcoming_songs.text = self.__upcoming
|
||||
self.ids.progressbars.value = float(self.songpos / float(self.songlength) * 100)
|
||||
self.isplaying = False
|
||||
Clock.schedule_interval(self.updateProgressbar, 0.1)
|
||||
|
||||
def updateScreen(self, dmp):
|
||||
Window.fullscreen = comHandler.checkiffullscreen(address)
|
||||
self.status = comHandler.checkgo(address)
|
||||
if self.status == "playing":
|
||||
self.isplaying = True
|
||||
elif self.status == "paused":
|
||||
self.isplaying = False
|
||||
elif self.status == "stopped":
|
||||
Window.fullscreen = False
|
||||
screen_manager.current = "Login"
|
||||
else:
|
||||
print("ERROR in Status. Please check connection!")
|
||||
Window.maximize()
|
||||
self.__windowsize = Window._get_size()
|
||||
self.__windowsize_x = self.__windowsize[0]
|
||||
@@ -71,29 +84,19 @@ class ShowcaseScreen(MDScreen):
|
||||
self.ids.upcoming_songs.font_size = self.__text_size - 5
|
||||
self.ids.titleinfo.font_size = self.__text_size * 2.2
|
||||
self.ids.upcoming_ind.font_size = self.__text_size + 10
|
||||
self.songpos = comHandler.getsongpos(address)
|
||||
if self.songpos < self.lastsongpos:
|
||||
self.__doupdateUI = comHandler.getuiupdate(address)
|
||||
if self.__doupdateUI:
|
||||
self.songpos = comHandler.getsongpos(address)
|
||||
self.__current = comHandler.getcurrentsong(address)
|
||||
self.__upcoming = comHandler.getupcomingsongs(address)
|
||||
self.songlength = comHandler.getsonglength(address)
|
||||
elif self.songpos > self.lastsongpos:
|
||||
self.isplaying = True
|
||||
elif self.songpos == self.lastsongpos:
|
||||
self.isplaying = False
|
||||
else:
|
||||
pass
|
||||
self.lastsongpos = self.songpos
|
||||
self.ids.current_song.text = self.__current
|
||||
self.ids.upcoming_songs.text = self.__upcoming
|
||||
if comHandler.checkgo(address):
|
||||
pass
|
||||
else:
|
||||
Window.fullscreen = False
|
||||
screen_manager.current = "Login"
|
||||
self.ids.progressbars.value = float(self.songpos / float(self.songlength) * 100)
|
||||
self.ids.current_song.text = self.__current
|
||||
self.ids.upcoming_songs.text = self.__upcoming
|
||||
|
||||
def updateProgressbar(self, dmp):
|
||||
if self.isplaying:
|
||||
self.__songdisplay = float(self.songpos / float(self.songlength) * 100)
|
||||
self.__songdisplay = float(self.songpos / float(self.songlength) * 100) - 1
|
||||
self.songpos += 0.1
|
||||
self.ids.progressbars.value = self.__songdisplay
|
||||
|
||||
|
||||
Reference in New Issue
Block a user