From 52a15342e5f9c43e93f0abad68de89d680ff41e8 Mon Sep 17 00:00:00 2001 From: janis Date: Sun, 30 Oct 2022 19:05:49 +0100 Subject: [PATCH] almost-stable-V2.0 --- bin/__pycache__/csv_parsers.cpython-310.pyc | Bin 4868 -> 4868 bytes .../filepathanalysis.cpython-310.pyc | Bin 1075 -> 1075 bytes bin/__pycache__/player.cpython-310.pyc | Bin 3270 -> 3343 bytes bin/__pycache__/servercoms.cpython-310.pyc | Bin 1530 -> 2024 bytes bin/gui/gui.kv | 67 +++++++++++++-- bin/player.py | 4 +- bin/servercoms.py | 20 ++++- data/config.csv | 2 +- data/songtemp.csv | 6 +- data/temp.csv | 2 +- musicplayer.py | 76 +++++++++++++++--- nodeserver/server.js | 23 +++++- .../__pycache__/comHandler.cpython-310.pyc | Bin 1759 -> 1884 bytes .../__pycache__/csv_parsers.cpython-310.pyc | Bin 4888 -> 4888 bytes showcaseScreen/handlers/comHandler.py | 14 +++- showcaseScreen/musicplayer_showcase_screen.py | 5 ++ 16 files changed, 185 insertions(+), 34 deletions(-) diff --git a/bin/__pycache__/csv_parsers.cpython-310.pyc b/bin/__pycache__/csv_parsers.cpython-310.pyc index b2edd5e23f55af1aa2948affa59c064c9e9021af..aaf40057efc5a5f813e17f193a080b1a49628919 100644 GIT binary patch delta 20 acmZosYfKMr`EPU;zLx;{-ea diff --git a/bin/__pycache__/player.cpython-310.pyc b/bin/__pycache__/player.cpython-310.pyc index b6b71ce955c03e3ff27c7f94241fa7325ca6bbb9..89b42d2becfcc63e1ce2c86bde78c0e8722295f2 100644 GIT binary patch delta 632 zcmY*W&1(}u6rY*wZj$}TciXgTjjd6GrKvZ)7*VlMp?-ppL(9?`mraxHGCNgT14Sx= zr&0zFdfHqh2N9$oc=RIp2lTR_XVJ4~eUpOXJN(}7eaw45-h7_in{qZB$3$R1-ma`2 z?mH*&^ZoO!8x&F8HQOfBI#z5CP}>2Pi}Sz=BUS`fV%fM1zQQW;7$pOY(ITQLsy#zg z+a>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F=`OXkA>AP@*r(WmRwH(xo^2LS)Z2Q6pz=`J zOAh*WU9`H*c~{iM!1bbw>LUjSKNRfMB~$nHK5unJ&|`*dO*Uzs{0Jy%CERlB?G_GO z!&3k{T7G0)_cor7yT)E24 ztu!a6IJqb_HSZP|f*s;k1huN3MZypvt_8AR7)Vq}2B#L4r4~8o=N9Xsn&YR*HCdHi zONs}iRtQ9hfCw=VAps(!CKt0S$_fCP91I+c9LyZ-5Xi$`!~_)7WGZ5xyp`P;0OV9o Ai2wiq diff --git a/bin/gui/gui.kv b/bin/gui/gui.kv index 8ae3273..ccf6930 100755 --- a/bin/gui/gui.kv +++ b/bin/gui/gui.kv @@ -6,6 +6,19 @@ RootScreen: ########### # POPUPS ########### +: + title: "App is quitting" + auto_dismiss: False + GridLayout: + cols: 1 + Label: + text: "App is closing remaining processes..." + font_size: 30 + Label: + text: "Please wait..." + font_size: 20 + + : title: "Connect to Server" auto_dismiss: False @@ -21,10 +34,16 @@ RootScreen: text: "" id: url hint_text: "Enter Server-IP" - Button: - text: "Connect" - on_release: - root.tryconnect() + GridLayout: + cols: 2 + Button: + text: "Connect" + on_release: + root.tryconnect() + Button: + text: "Cancel" + on_release: + root.dismiss() : @@ -43,6 +62,7 @@ RootScreen: text: "Yes" font_size: 15 on_release: + root.quitapp() app.stop() Button: text: "No" @@ -107,6 +127,24 @@ RootScreen: on_release: root.dismiss() +: + title: "NOTICE!" + font_size: 50 + size_hint: 0.5, 0.4 + auto_dismiss: False + GridLayout: + cols:1 + Label: + text: "You are not connected to a server!" + font_size: 18 + Label: + text: "Therefore this function is not available!" + font_size: 15 + Button: + text:"Ok" + on_release: + root.dismiss() + : title: "DISABLE FULLSCREEN AND LEAVE" font_size: 50 @@ -161,7 +199,7 @@ RootScreen: pos_hint: {"x":0.2, "y":0.5} size_hint_x: 0.6 focus: True - text: "" + text: "/mnt/storage/SORTED/Music" on_text: root.autocomplete() on_text_validate: @@ -173,7 +211,7 @@ RootScreen: text_size: self.size id: cmd_output GridLayout: - cols: 2 + cols: 3 Button: text: "Start" color: app.theme_cls.primary_color @@ -182,6 +220,14 @@ RootScreen: background_color: app.theme_cls.accent_dark on_release: root.change_screen() + Button: + text: "Connect to Server" + color: app.theme_cls.primary_color + font_size: 30 + bold: True + background_color: app.theme_cls.accent_dark + on_release: + root.connectServer() Button: text: "Quit" color: app.theme_cls.primary_color @@ -246,16 +292,21 @@ RootScreen: on_release: root.go_back() Button: - text: "Connect to Server" + text: "Fullscreen on client\n(Only available if connected)" + id: fullscreenc background_color: app.theme_cls.accent_dark on_release: - root.connectToServer() + root.changeServerSettings() Button: text: "Showcase" background_color: app.theme_cls.accent_dark on_release: app.root.current = "Showcase" root.manager.transition.direction = "left" + Label: + text: "Test" + id: connectstatus + pos_hint: {"y": -0.45} : on_pre_enter: root.reset() diff --git a/bin/player.py b/bin/player.py index afdc87c..9c92aaa 100755 --- a/bin/player.py +++ b/bin/player.py @@ -27,10 +27,10 @@ class Player: def start_playing(self): # initialize playing + print("starting player") if pygame.get_init() == True: pass else: - pygame.init() self.path = cvr.importing("./data/temp.csv").pop(0) self.pathtr = self.path.pop(0) self.__imports = pa.validsonglistcreator(self.pathtr) @@ -135,4 +135,4 @@ class Player: self.infoupdater() else: pass - time.sleep(0.25) + time.sleep(0.2) diff --git a/bin/servercoms.py b/bin/servercoms.py index b54b320..d1bebd0 100644 --- a/bin/servercoms.py +++ b/bin/servercoms.py @@ -39,10 +39,24 @@ class ServerComs: except Exception: return False - def postfullscreen(self, url, data): + def changefullscreen(self, url): try: - self.x = requests.post(f"{url}/postfullscreen", {"fullscreen":data}) + self.x = requests.get(f"{url}/changefullscreen") + return True + except Exception: + return False + + def getfullscreeninfo(self, url): + try: + self.x = requests.get(f"{url}/changefullscreen") + except Exception: + pass + return self.x.text + + def poststatus(self, url, isalive): + print("updating status") + try: + self.x = requests.post(f"{url}/poststatus", {"status":f"{isalive}"}) return True except Exception: return False - \ No newline at end of file diff --git a/data/config.csv b/data/config.csv index 1c99470..4e16fcf 100755 --- a/data/config.csv +++ b/data/config.csv @@ -1 +1 @@ -0,songlist.csv +1,songlist.csv diff --git a/data/songtemp.csv b/data/songtemp.csv index f3b0412..7a5bba3 100755 --- a/data/songtemp.csv +++ b/data/songtemp.csv @@ -1,3 +1,3 @@ -9 -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) -251.97134399414062 +0 +Lupus Nocte - Hadouken (Royalty Free Music).mp3,Minecraft OST - Pigstep.mp3,The Day You Went Away.mp3,sha la la.mp3 +163.7987518310547 diff --git a/data/temp.csv b/data/temp.csv index 67aab75..410a3c6 100755 --- a/data/temp.csv +++ b/data/temp.csv @@ -1 +1 @@ -/mnt/storage/SORTED/Music/ +/mnt/storage/SORTED/Music diff --git a/musicplayer.py b/musicplayer.py index 1152840..3c65614 100755 --- a/musicplayer.py +++ b/musicplayer.py @@ -1,3 +1,4 @@ +from audioop import add import os import configparser @@ -45,8 +46,13 @@ address = "" # Popups ########### +class AppQuitting(Popup): + pass + + class ConnectPU(Popup): def tryconnect(self): + print("trying to connect") self.url = self.ids.url.text self.containsPort = False for self.letter in self.url: @@ -57,20 +63,26 @@ class ConnectPU(Popup): self.connectionurl = "" if self.url[:8] != "https://" and self.url[:7] != "http://" and self.url[len(self.url) - 1:] == "/" and not self.containsPort and len(self.url) > 2: self.connectionurl = f"http://{self.url[:len(self.url) - 1]}:8000" - print(svc.connect(self.connectionurl)) - self.dismiss() + if svc.connect(self.connectionurl): + self.dismiss() + else: + self.ids.output.text = "There was an error in connecting to the server! Please make sure that the ip is correct!" elif self.url[:8] != "https://" and self.url[:7] != "http://" and self.url[len(self.url) - 1:] != "/" and not self.containsPort and len(self.url) > 2: self.connectionurl = f"http://{self.url}:8000" - print(svc.connect(self.connectionurl)) - self.dismiss() + if svc.connect(self.connectionurl): + self.dismiss() + else: + self.ids.output.text = "There was an error in connecting to the server! Please make sure that the ip is correct!" else: - self.ids.output = "Invalid address, please enter just the IP address!" + self.ids.output.text = "Invalid address, please enter just the IP address!" global address address = self.connectionurl class QuitPU(Popup): - pass + def quitapp(self): + svc.poststatus(address, False) + time.sleep(1) class PathMissingPU(Popup): @@ -85,6 +97,10 @@ class invalidpathPU(Popup): pass +class NotConnected(Popup): + pass + + class LeavePU(Popup): def check_pwd(self): if self.ids.passw.text == config["Security"]["pwd"]: @@ -123,7 +139,6 @@ class Home(MDScreen): self.__good_files += 1 else: pass - # self.__good_files = 1 if self.__good_files > 0: cvw.write_str("./data/temp.csv", [self.ids.filepath.text]) self.manager.current = "Main" @@ -161,6 +176,9 @@ class Home(MDScreen): def quitapp(self): QuitPU().open() + + def connectServer(self): + ConnectPU().open() class Main(MDScreen): @@ -172,6 +190,8 @@ class Main(MDScreen): self.keyboard = Window.request_keyboard(None, self) self.keyboard.bind(on_key_down=self.key_pressed) self.quit_requests = 0 + self.__comparepos = 10000 + global address def key_pressed(self, keyboard, keycode, text, modifiers): # print(keycode[1]) @@ -202,11 +222,19 @@ class Main(MDScreen): pass def initialize(self): + if address != "": + self.ids.connectstatus.text = f"Connected to: {address}" + svc.poststatus(address, True) + if svc.getfullscreeninfo == "True": + self.ids.fullscreenc.text = "Exit fullscreen on client display" + else: + self.ids.fullscreenc.text = 'Enter fullscreen on client display' + else: + self.ids.connectstatus.text = "not connected to any server" try: self.refreshspeed = int(config["Performance"]["showcaseRefreshRate"]) except ValueError: self.refreshspeed = 1 - try: Clock.schedule_interval(self.screen_updating, self.refreshspeed) except: @@ -253,6 +281,7 @@ class Main(MDScreen): self.mplayer.kill() except: pass + svc.poststatus(address, False) self.ids.pp_button.text = "Play" self.manager.current = "Home" self.manager.transition.direction = "right" @@ -274,7 +303,8 @@ class Main(MDScreen): self.__upcoming = self.__info.pop(0) self.__songlinfo = self.__info.pop(0) self.__songpos = self.backfeed.value - self.__songdisplay = int(self.__songpos / float(self.__songlinfo.pop(0)) * 100) + self.__songlength = self.__songlinfo.pop(0) + self.__songdisplay = int(self.__songpos / float(self.__songlength) * 100) self.manager.get_screen("Showcase").ids.progressbars.value = self.__songdisplay self.__current = self.__upcoming.pop(self.__currents) if self.__config == ["1"]: @@ -304,6 +334,18 @@ class Main(MDScreen): self.__upcoming_output += f"\n{self.__upcoming2}" 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: + svc.postcurrentsong(address, self.__current_output) + svc.postsonglength(address, self.__songlength) + svc.postupcomingsongs(address, self.__upcoming_output) + # svc.postfullscreen(address, self.__current_output) + else: + pass + self.__comparepos = self.__songpos + else: + pass def back_here(self): if self.manager.current == "Showcase": @@ -317,8 +359,16 @@ class Main(MDScreen): def open_leave_popup(self): LeavePU().open() - def connectToServer(self): - ConnectPU().open() + def changeServerSettings(self): + if address != "": + svc.changefullscreen(address) + if svc.getfullscreeninfo == "True": + self.ids.fullscreenc.text = "Exit fullscreen on client display" + else: + self.ids.fullscreenc.text = 'Enter fullscreen on client display' + else: + NotConnected().open() + class ShowcaseS(MDScreen): @@ -347,7 +397,11 @@ class MusicPlayer(MDApp): return Builder.load_file("./bin/gui/gui.kv") def on_request_close(self, *args): + global address + AppQuitting().open() print("leaving...") + svc.poststatus(address, False) + time.sleep(1) os.killpg(os.getpgid(0), signal.SIGKILL) diff --git a/nodeserver/server.js b/nodeserver/server.js index ddca80e..e985b37 100644 --- a/nodeserver/server.js +++ b/nodeserver/server.js @@ -14,6 +14,7 @@ var upcomingsongs = "Test\nTest2\nTest3" var currentsong = "This is a song" var songmaxlength = "100" var fullscreen = "False" +var isrunning = "False" // CONFIG FOR EXPRESS @@ -36,6 +37,7 @@ app.get('/playbackpos', (request, response) => { }) app.get('/upcomingsongs', (request, response) => { + console.log("getting upcoming songs") response.send(upcomingsongs) }) @@ -51,6 +53,10 @@ app.get('/fullscreen', (request, response) => { response.send(fullscreen) }) +app.get('/isrunning', (request, response) => { + response.send(isrunning) +}) + // POST data (Interface for Player) app.post('/postplayback', (request, response) => { @@ -58,7 +64,8 @@ app.post('/postplayback', (request, response) => { response.send("ok") }) -app.post('/postupcomingsogns', (request, response) => { +app.post('/postupcomingsongs', (request, response) => { + console.log("updating upcomingsongs") upcomingsongs = request.body.songs response.send("ok") }) @@ -68,8 +75,12 @@ app.post('/postcurrentsong', (request, response) => { response.send("ok") }) -app.post('/postfullscreen', (request, response) => { - fullscreen = request.body.fullscreen +app.post('/changefullscreen', (request, response) => { + if (fullscreen == "True") { + fullscreen = "False" + } else { + fullscreen = "True" + } response.send("ok") }) @@ -78,6 +89,12 @@ app.post('/postsonglength', (request, response) => { response.send("ok") }) +app.post('/poststatus', (request, response) => { + console.log("updating status " + request.body.status) + isrunning = request.body.status + response.send("ok") +}) + // Test functions app.post('/testrequest', (request, response) => { diff --git a/showcaseScreen/handlers/__pycache__/comHandler.cpython-310.pyc b/showcaseScreen/handlers/__pycache__/comHandler.cpython-310.pyc index 93ce50d83f63389bc877e9e7d6a570e5e6885d22..8b0b2f1e6f2fd72f196260202069431873cd6d3f 100644 GIT binary patch delta 203 zcmcc5dxwuNpO=@50SJ6n#3lQ(P2`JV^qH9L%9A3{!VtxkA{fk|DYS75KQjkwT26jq zNfF;Pm_DH7MnAhB1l$w@sHf?4