diff --git a/bin/__pycache__/csv_parsers.cpython-310.pyc b/bin/__pycache__/csv_parsers.cpython-310.pyc index b2edd5e..aaf4005 100644 Binary files a/bin/__pycache__/csv_parsers.cpython-310.pyc and b/bin/__pycache__/csv_parsers.cpython-310.pyc differ diff --git a/bin/__pycache__/filepathanalysis.cpython-310.pyc b/bin/__pycache__/filepathanalysis.cpython-310.pyc index 1a35336..39673c2 100644 Binary files a/bin/__pycache__/filepathanalysis.cpython-310.pyc and b/bin/__pycache__/filepathanalysis.cpython-310.pyc differ diff --git a/bin/__pycache__/player.cpython-310.pyc b/bin/__pycache__/player.cpython-310.pyc index b6b71ce..89b42d2 100644 Binary files a/bin/__pycache__/player.cpython-310.pyc and b/bin/__pycache__/player.cpython-310.pyc differ diff --git a/bin/__pycache__/servercoms.cpython-310.pyc b/bin/__pycache__/servercoms.cpython-310.pyc index e15932f..c42b98f 100644 Binary files a/bin/__pycache__/servercoms.cpython-310.pyc and b/bin/__pycache__/servercoms.cpython-310.pyc differ 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 93ce50d..8b0b2f1 100644 Binary files a/showcaseScreen/handlers/__pycache__/comHandler.cpython-310.pyc and b/showcaseScreen/handlers/__pycache__/comHandler.cpython-310.pyc differ diff --git a/showcaseScreen/handlers/__pycache__/csv_parsers.cpython-310.pyc b/showcaseScreen/handlers/__pycache__/csv_parsers.cpython-310.pyc index bb001c5..33cf206 100644 Binary files a/showcaseScreen/handlers/__pycache__/csv_parsers.cpython-310.pyc and b/showcaseScreen/handlers/__pycache__/csv_parsers.cpython-310.pyc differ diff --git a/showcaseScreen/handlers/comHandler.py b/showcaseScreen/handlers/comHandler.py index 9fb95ea..2f2544e 100644 --- a/showcaseScreen/handlers/comHandler.py +++ b/showcaseScreen/handlers/comHandler.py @@ -29,7 +29,7 @@ class Com: self.x = requests.get(f"{url}/songmaxlength") except Exception: return 100 - return int(self.x.text) + return float(self.x.text) def getupcomingsongs(self, url): try: @@ -43,7 +43,7 @@ class Com: self.x = requests.get(f"{url}/playbackpos") except Exception: return 0 - return int(self.x.text) + return float(self.x.text) def checkiffullscreen(self, url): try: @@ -52,5 +52,15 @@ class Com: return False if self.x.text == "True": return True + else: + return False + + def checkgo(self, url): + try: + self.x = requests.get(f"{url}/isrunning") + except Exception: + return False + if self.x.text == "True": + return True else: return False \ No newline at end of file diff --git a/showcaseScreen/musicplayer_showcase_screen.py b/showcaseScreen/musicplayer_showcase_screen.py index 9714fb5..7999920 100644 --- a/showcaseScreen/musicplayer_showcase_screen.py +++ b/showcaseScreen/musicplayer_showcase_screen.py @@ -72,6 +72,11 @@ class ShowcaseScreen(MDScreen): self.ids.progressbars.value = self.__songdisplay 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" class MusicPlayerShowcaseScreen(MDApp):