From f1f3d5461c6e7fef400cd06dfd70db3a74288ed7 Mon Sep 17 00:00:00 2001 From: janis Date: Fri, 11 Mar 2022 19:19:20 +0100 Subject: [PATCH] Beta-1.0.1: - added a function to go back to previous song --- bin/gui/gui.kv | 80 +++++++++++++++++++++++++++++---------------- bin/info_handler.py | 7 +++- bin/player.py | 16 +++++++++ data/songtemp.csv | 4 +-- musicplayer.py | 18 +++++++++- 5 files changed, 93 insertions(+), 32 deletions(-) diff --git a/bin/gui/gui.kv b/bin/gui/gui.kv index 88907f8..bef75b3 100644 --- a/bin/gui/gui.kv +++ b/bin/gui/gui.kv @@ -87,7 +87,7 @@ RootScreen: hint_text: "Path to Folder containing the Music files" pos_hint: {"x":0.2, "y":0.5} size_hint_x: 0.6 - text: "/home/janis/Downloads" + text: "/home/janis/Downloads/KB" Button: text: "Start" color: app.theme_cls.primary_color @@ -100,34 +100,55 @@ RootScreen:
: on_pre_enter: root.initialize() name: "Main" + md_bg_color: app.theme_cls.accent_color GridLayout: cols: 1 - GridLayout: - cols: 2 - Button: - text: "Next" - on_release: - root.nextsong() - Button: - text: "Rewind" - on_release: - root.rewindsong() - Button: - text: "Play" - id: pp_button - on_release: - root.playmusic() - GridLayout: - cols: 2 - Button: - text: "Back" - on_release: - root.go_back() - Button: - text: "Showcase" - on_release: - app.root.current = "Showcase" - root.manager.transition.direction = "left" + Label: + text: "MusicPlayer" + font_size: 40 + color: app.theme_cls.primary_color + FloatLayout: + GridLayout: + size_hint: 0.8, 0.9 + pos_hint: {"x": 0.1, "y": 0.1} + cols: 1 + GridLayout: + cols: 3 + Button: + text: "Previous" + background_color: app.theme_cls.accent_dark + on_release: + root.previoussong() + Button: + text: "Rewind" + background_color: app.theme_cls.accent_dark + on_release: + root.rewindsong() + Button: + text: "Next" + background_color: app.theme_cls.accent_dark + on_release: + root.nextsong() + + Button: + text: "Play" + id: pp_button + background_color: app.theme_cls.accent_dark + on_release: + root.playmusic() + GridLayout: + cols: 2 + Button: + text: "Back" + background_color: app.theme_cls.accent_dark + on_release: + root.go_back() + Button: + text: "Showcase" + background_color: app.theme_cls.accent_dark + on_release: + app.root.current = "Showcase" + root.manager.transition.direction = "left" : on_pre_enter: root.screen_updater_start() @@ -170,4 +191,7 @@ RootScreen: background_color: app.theme_cls.accent_light on_release: app.root.current = "Main" - root.manager.transition.direction = "right" \ No newline at end of file + root.manager.transition.direction = "right" + +: + name: "Settings" \ No newline at end of file diff --git a/bin/info_handler.py b/bin/info_handler.py index c2df210..bc9525a 100644 --- a/bin/info_handler.py +++ b/bin/info_handler.py @@ -26,7 +26,12 @@ class InfoHandler: try: self.__style = self.__infos.pop(0) self.__outp1 += f" | {self.__style}" - except: + except IndexError: + pass + try: + self.__tempo = self.__infos.pop(0) + self.__outp1 += f" ({self.__tempo})" + except IndexError: 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 6c82b8c..85e93ab 100644 --- a/bin/player.py +++ b/bin/player.py @@ -83,6 +83,22 @@ class Player: elif other.value == 3: self.__recent_change = 1000000 other.value = 0 + + elif other.value == 4: + other.value = 0 + mx.music.unload() + self.playlist = copy.deepcopy(self.playlist_backup) + if self.current_playing_pos > 0: + self.current_playing_pos -= 1 + else: + self.current_playing_pos = len(self.playlist_backup) - 1 + for i in range(self.current_playing_pos): + self.playlist.pop(0) + self.current_playing = self.playlist.pop(0) + mx.music.load(self.current_playing) + mx.music.play() + self.__recent_change = 10000000 + self.infoupdater() else: if inst.value == 1: mx.music.unpause() diff --git a/data/songtemp.csv b/data/songtemp.csv index 2184992..db3fea0 100644 --- a/data/songtemp.csv +++ b/data/songtemp.csv @@ -1,2 +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 +8 +Tennessee Waltz - New 101 Strings Orchestra | Slow Walz (lansam),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 (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 | walzer/slow (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),Staiin' Alive - Begees | Discofox (Mittel),Easy On Me - Adele | Langsam (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) diff --git a/musicplayer.py b/musicplayer.py index 1cbb5fe..c61dcb1 100644 --- a/musicplayer.py +++ b/musicplayer.py @@ -99,8 +99,10 @@ class Main(MDScreen): self.playmusic() elif self.key == "right": self.nextsong() - elif self.key == "left": + elif self.key == "up": self.rewindsong() + elif self.key == "left": + self.previoussong() else: pass @@ -130,6 +132,9 @@ class Main(MDScreen): def rewindsong(self): self.others.value = 2 + def previoussong(self): + self.others.value = 4 + def go_back(self): try: self.mplayer.kill() @@ -138,6 +143,17 @@ class Main(MDScreen): self.manager.current = "Home" self.manager.transition.direction = "right" + def show_current_song(self): + 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.__current = self.__upcoming.pop(self.__currents) + if self.__config == ["1"]: + self.ids.current_song.text = self.__current[:(len(self.__current) - 4)] + else: + self.ids.current_song.text = self.__current class ShowcaseS(MDScreen): def screen_updater_start(self):