From 92350fc5aa13a098aaee3872042e08110cb63c99 Mon Sep 17 00:00:00 2001 From: janis Date: Fri, 11 Mar 2022 17:59:14 +0100 Subject: [PATCH] Beta-1.0: - added new option to show song titles --- bin/gui/gui.kv | 11 +++++++---- bin/info_handler.py | 27 +++++++++++++++++++++------ bin/player.py | 8 +++++--- data/config.csv | 2 +- data/songtemp.csv | 1 + musicplayer.py | 31 ++++++++++++++++++++++++++----- 6 files changed, 61 insertions(+), 19 deletions(-) diff --git a/bin/gui/gui.kv b/bin/gui/gui.kv index 37c685e..88907f8 100644 --- a/bin/gui/gui.kv +++ b/bin/gui/gui.kv @@ -136,23 +136,25 @@ RootScreen: FloatLayout: Label: text: "Currently Playing" - pos_hint: {"y": 0.4} - font_size: 35 + pos_hint: {"y": 0.35} + font_size: 45 color: app.theme_cls.primary_color MDProgressBar: orientation: "horizontal" value: 100 - pos_hint: {"y": 0.35} + pos_hint: {"y": 0.3} color: app.theme_cls.primary_dark Label: id: current_song text: "Currently playing Song will appear here" - pos_hint: {"y": 0.25} + pos_hint: {"y": 0.22} font_size: 30 color: app.theme_cls.primary_color + shorten: False Label: text: "upcoming" font_size: 25 + pos_hint: {"y": -0.05} color: app.theme_cls.primary_color Label: id: upcoming_songs @@ -160,6 +162,7 @@ RootScreen: pos_hint: {"y": -0.25} font_size: 20 color: app.theme_cls.primary_color + shorten: False Button: text: "back" font_size: 10 diff --git a/bin/info_handler.py b/bin/info_handler.py index 9df72fc..c2df210 100644 --- a/bin/info_handler.py +++ b/bin/info_handler.py @@ -7,11 +7,26 @@ cvw = bin.csv_parsers.CsvWrite() class InfoHandler: def __init__(self): - pass + self.path = "" + self.__infos = "" + self.__style = "" + self.__outp1 = "" + self.__output = [] - def infohandler(self, infos, path): - print(path, "path") - self.path = f"{path}/songlist.csv" + def infohandler(self, listname, path): + self.path = f"{path}/{listname}" self.__info_doc = cvr.importing(self.path) - print(self.__info_doc) - print(infos) + self.__outp1 = "" + self.__output = [] + for self.item in self.__info_doc: + self.__outp1 = [] + self.__infos = "" + self.__infos = self.item + self.__outp1 = f"{self.__infos.pop(0)} - {self.__infos.pop(0)}" + try: + self.__style = self.__infos.pop(0) + self.__outp1 += f" | {self.__style}" + except: + pass + self.__output.append(self.__outp1) + cvw.app_str("./data/songtemp.csv", self.__output) diff --git a/bin/player.py b/bin/player.py index 627d459..6c82b8c 100644 --- a/bin/player.py +++ b/bin/player.py @@ -43,11 +43,14 @@ class Player: self.transmission = [] cvw.write_str("./data/songtemp.csv", [self.current_playing_pos]) self.__config = cvr.importing("./data/config.csv").pop(0) + self.listinfo = self.__config.pop(1) if self.__config == ["1"]: cvw.app_str("./data/songtemp.csv", self.information) else: - print(self.path, "path") - bin.info_handler.InfoHandler().infohandler(self.information, self.pathtr) + try: + bin.info_handler.InfoHandler().infohandler(self.listinfo, self.pathtr) + except FileNotFoundError: + cvw.app_str("./data/songtemp.csv", self.information) def musicmanager(self, inst, other): self.start_playing() @@ -101,4 +104,3 @@ class Player: self.infoupdater() else: pass - diff --git a/data/config.csv b/data/config.csv index c227083..2762949 100644 --- a/data/config.csv +++ b/data/config.csv @@ -1 +1 @@ -0 \ No newline at end of file +0,songlist.csv \ No newline at end of file diff --git a/data/songtemp.csv b/data/songtemp.csv index 573541a..2184992 100644 --- a/data/songtemp.csv +++ b/data/songtemp.csv @@ -1 +1,2 @@ 0 +Tennessee Waltz - New 101 Strings Orchestra | Slow Walz,Morning has broken - Cat Stevens | Walzer,Magia - Alvaro Soler | Flashmob,Say So - Doja Cat | Discofox,Save Your Tears (Remix) - The Weeknd & Ariana Grande | Discofox,Shivers - Ed Sheeran | Jive/ Rocknroll,I feel good - Ray Charles | Jive/Rocknroll,Muevelo - Rey Ruiz | Cha ch cha,suelta la cintura - Ruben leon | Cha ch cha,Como Volver a Ser Feliz - Luis Enrique | Salsa,Mas que nada - black eyed peas | Salsa/Discofox,Moon River - Henry Mancini | Slow Walz,Dancing Queen - ABBA | Discofox,Don't Call Me Up - Mabel | Discofox,Magia - Alvaro Soler | Flashmob,Lets have a Party - Wanda Jackson | Jive,Crazy Little Thing Called Love - Queen | Jive / Rocknroll,El Diablo Anda Suelto - Rey Ruiz | Cha ch cha,Lets get loud - jennifer Lopez | Cha ch cha,Enamorame - Somos del Barrio | Salsa,Something Stupid (feat. Reese Witherspoon) - Michael Bublé | Rumba/cha cha cha,When a man loves a woman - Percy Sledge | Slow,Scharlachrot - Patent Ochsner | Walzer,ily (i love you baby) [feat. Emilee] - Surf Mesa | Discofox,Like a sex machine - James Brown | Discofox,Uptown Funk (feat. Bruno Mars) - Discofox | Discofox,Tutti Frutti - Little Richard | Jive/ Rocknroll,Jailhouse Rock - Elvis Presley | Jive/ Rocknroll,Are you lonesome - Elvis Presley | walzer/slow,Ay Mujer - Rey Ruiz | Cha ch cha,Rico Vacilon - Pedro Garcia & His Del Prado Orchestra | Cha ch cha,Jeepers creepers - Benny Goodmann | Foxtrott,An der schönen blauen Donau - New 101 Strings Orchestra | Wiener Walzer,The Last Waltz - Engelbert Humperdinck | Walzer,Stand by me - Sam Brown | Cha ch cha,Staiin' Alive - Begees | Discofox,Easy On Me - Adele | Slow,Magia - Alvaro Soler | Flashmob,Friday (feat. Mufasa & Hypeman) [Dopamine Re-Edit] - Riton & Nightcrawlers | Party,YMCA - Village People | Party,Cotton eyed Joe (Hennustall zermatt mix) - Rednex,Gangnam style - PSY | Party,Take On Me - a-ha | Jive,Rock Around the Clock - Bill Haley & His Comets | Jive/Rocknroll,Satisfaction - Rolling Stones | Party,"Un, dos, tres - Ricky Martin | Party",Party Rock anthem - LFMBQ | Party,I don't care - Icona Pop | Party,Love tonight - Shouse&David Guetta | Party,Insomnia - Faithless | Party,Angels - Robbie Williams | Slow,Nothing compares to you - Sinead O'Connor | Slow diff --git a/musicplayer.py b/musicplayer.py index c7a5be9..1cbb5fe 100644 --- a/musicplayer.py +++ b/musicplayer.py @@ -1,5 +1,7 @@ import multiprocessing import os +import signal + from kivy.core.window import Window, Config from kivy.uix.screenmanager import ScreenManager from kivymd.uix.screen import MDScreen @@ -10,6 +12,7 @@ from kivy.clock import Clock import bin.csv_parsers import bin.filepathanalysis import bin.player +import sys pl = bin.player.Player() @@ -135,45 +138,63 @@ class Main(MDScreen): self.manager.current = "Home" self.manager.transition.direction = "right" + class ShowcaseS(MDScreen): def screen_updater_start(self): Clock.schedule_interval(self.screen_updating, 2) - def screen_updating(self, waste): + self.__config = cvr.importing("./data/config.csv").pop(0) self.__info = cvr.importing("./data/songtemp.csv") self.__currents_imp = self.__info.pop(0) self.__currents = int(self.__currents_imp.pop(0)) self.__upcoming = self.__info.pop(0) - self.__upcoming.sort() self.__current = self.__upcoming.pop(self.__currents) - self.ids.current_song.text = self.__current[:(len(self.__current) - 4)] + if self.__config == ["1"]: + self.ids.current_song.text = self.__current[:(len(self.__current) - 4)] + else: + self.ids.current_song.text = self.__current if len(self.__upcoming) <= self.__currents: self.ids.upcoming_songs.text = "No more songs in Queue" else: self.__upcoming2 = str(self.__upcoming.pop(self.__currents)) - self.__upcoming_output = self.__upcoming2[:(len(self.__upcoming2) - 4)] + if self.__config == ["1"]: + self.__upcoming_output = self.__upcoming2[:(len(self.__upcoming2) - 4)] + else: + self.__upcoming_output = self.__upcoming2 + self.__length_output = 0 for i in range(len(self.__upcoming) - self.__currents): if self.__length_output > 5: pass else: self.__upcoming2 = str(self.__upcoming.pop(self.__currents)) - self.__upcoming_output += f"\n{self.__upcoming2[:(len(self.__upcoming2) - 4)]}" + if self.__config == ["1"]: + self.__upcoming_output += f"\n{self.__upcoming2[:(len(self.__upcoming2) - 4)]}" + else: + self.__upcoming_output += f"\n{self.__upcoming2}" self.__length_output += 1 self.ids.upcoming_songs.text = self.__upcoming_output + class RootScreen(ScreenManager): pass + class MusicPlayer(MDApp): def build(self): + Window.bind(on_request_close=self.on_request_close) self.title = "MusicPlayer" self.theme_cls.primary_palette = "Yellow" self.theme_cls.accent_palette = "BlueGray" # self.icon = "./BiogasControllerAppLogo.png" return Builder.load_file("./bin/gui/gui.kv") + def on_request_close(self, *args): + print("leaving...") + os.killpg(os.getpgid(0), signal.SIGKILL) + + if __name__ == "__main__": Config.set('graphics', 'width', '800') Config.set('graphics', 'height', '600')