diff --git a/bin/csv_parsers.py b/bin/csv_parsers.py index d1f593c..c56faec 100644 --- a/bin/csv_parsers.py +++ b/bin/csv_parsers.py @@ -50,7 +50,7 @@ class CsvWrite: def chg_str(self, path, row, pos, new_value): - """Opens the csv-file in write mode to change a value, e.g. if a recipes is changed.""" + """Opens the csv-file in write mode to change a value, e.g. if a recipe is changed.""" self.__imp = open(path) self.__raw = csv.reader(self.__imp, delimiter=',') self.__impl = list(self.__raw) diff --git a/bin/gui/gui.kv b/bin/gui/gui.kv index b429193..f54ac20 100644 --- a/bin/gui/gui.kv +++ b/bin/gui/gui.kv @@ -67,7 +67,7 @@ RootScreen: : name: "Home" - md_bg_color: app.theme_cls.accent_color + md_bg_color: app.theme_cls.accent_dark GridLayout: cols: 1 Label: @@ -100,7 +100,7 @@ RootScreen:
: on_pre_enter: root.initialize() name: "Main" - md_bg_color: app.theme_cls.accent_color + md_bg_color: app.theme_cls.accent_dark GridLayout: cols: 1 GridLayout: @@ -163,33 +163,45 @@ RootScreen: FloatLayout: Label: text: "Currently Playing" + bold: True + italic: True pos_hint: {"y": 0.35} - font_size: 45 + font_size: 60 color: app.theme_cls.primary_color MDProgressBar: orientation: "horizontal" value: 100 pos_hint: {"y": 0.3} + color: (1, 1, 1, 0.5) + MDProgressBar: + id: progressbars + orientation: "horizontal" + value: 0 + 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.22} - font_size: 30 + font_size: 45 color: app.theme_cls.primary_color shorten: False + halign: "center" Label: text: "upcoming" - font_size: 25 + bold: True + italic: True + font_size: 35 pos_hint: {"y": -0.05} color: app.theme_cls.primary_color Label: id: upcoming_songs text: "Upcoming Songs will appear here" pos_hint: {"y": -0.25} - font_size: 20 + font_size: 30 color: app.theme_cls.primary_color shorten: False + halign: "center" Button: text: "back" font_size: 10 diff --git a/bin/player.py b/bin/player.py index 85e93ab..d77664b 100644 --- a/bin/player.py +++ b/bin/player.py @@ -18,6 +18,7 @@ class Player: self.__imports = [] self.information = [] self.current_playing_pos = 0 + self.__songlength = 0 def start_playing(self): # initialize playing @@ -40,6 +41,7 @@ class Player: mx.music.pause() def infoupdater(self): + self.__songlength = mx.Sound(self.current_playing).get_length() self.transmission = [] cvw.write_str("./data/songtemp.csv", [self.current_playing_pos]) self.__config = cvr.importing("./data/config.csv").pop(0) @@ -50,12 +52,15 @@ class Player: try: bin.info_handler.InfoHandler().infohandler(self.listinfo, self.pathtr) except FileNotFoundError: + cvw.chg_str("./data/config.csv", 0, 0, "1") cvw.app_str("./data/songtemp.csv", self.information) + cvw.app_str("./data/songtemp.csv", [self.__songlength]) - def musicmanager(self, inst, other): + def musicmanager(self, inst, other, backfeed): self.start_playing() self.infoupdater() while self.__running == 1: + backfeed.value = mx.music.get_pos() / 1000 if self.__recent_change < 1: pass else: @@ -77,7 +82,9 @@ class Player: self.infoupdater() elif other.value == 2: - mx.music.rewind() + mx.music.unload() + mx.music.load(self.current_playing) + mx.music.play() other.value = 0 elif other.value == 3: diff --git a/data/config.csv b/data/config.csv index 2762949..a571c40 100644 --- a/data/config.csv +++ b/data/config.csv @@ -1 +1 @@ -0,songlist.csv \ No newline at end of file +0,songlist.csv diff --git a/data/songtemp.csv b/data/songtemp.csv index 9ec82b1..b439d6b 100644 --- a/data/songtemp.csv +++ b/data/songtemp.csv @@ -1,2 +1,3 @@ -9 -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) +2 +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) +191.33242797851562 diff --git a/musicplayer.py b/musicplayer.py index e49b2e2..4ee080e 100644 --- a/musicplayer.py +++ b/musicplayer.py @@ -1,7 +1,7 @@ import multiprocessing import os import signal - +# os.environ["KIVY_NO_CONSOLELOG"] = "1" from kivy.core.window import Window, Config from kivy.uix.screenmanager import ScreenManager from kivymd.uix.screen import MDScreen @@ -12,6 +12,7 @@ from kivy.clock import Clock import bin.csv_parsers import bin.filepathanalysis import bin.player +import math pl = bin.player.Player() @@ -87,6 +88,7 @@ class Main(MDScreen): super().__init__(**kwargs) self.instructions = multiprocessing.Value('i', 0) self.others = multiprocessing.Value('i', 0) + self.backfeed = multiprocessing.Value('f', 0) self.keyboard = Window.request_keyboard(None, self) self.keyboard.bind(on_key_down=self.key_pressed) self.quit_requests = 0 @@ -123,14 +125,18 @@ class Main(MDScreen): if self.mplayer.is_alive() is True: pass else: + cvw.chg_str("./data/config.csv", 0, 0, "0") self.instructions = multiprocessing.Value('i', 0) self.others = multiprocessing.Value('i', 0) - self.mplayer = multiprocessing.Process(name="player", target=pl.musicmanager, args=(self.instructions, self.others,)) + self.backfeed = multiprocessing.Value('f', 0) + self.mplayer = multiprocessing.Process(name="player", target=pl.musicmanager, args=(self.instructions, self.others, self.backfeed,)) self.mplayer.start() - except: + except AttributeError: + cvw.chg_str("./data/config.csv", 0, 0, "0") self.instructions = multiprocessing.Value('i', 0) self.others = multiprocessing.Value('i', 0) - self.mplayer = multiprocessing.Process(name="player", target=pl.musicmanager, args=(self.instructions, self.others,)) + self.backfeed = multiprocessing.Value('f', 0) + self.mplayer = multiprocessing.Process(name="player", target=pl.musicmanager, args=(self.instructions, self.others, self.backfeed,)) self.mplayer.start() def playmusic(self): @@ -161,11 +167,22 @@ class Main(MDScreen): self.manager.transition.direction = "right" def screen_updating(self, waste): + self.__windowsize = Window._get_size() + self.__windowsize_x = self.__windowsize[0] + self.__windowsize_y = self.__windowsize[1] + self.__text_size = round(math.sqrt(((self.__windowsize_x + self.__windowsize_y) / 2)), 0) + self.manager.get_screen("Showcase").ids.current_song.font_size = self.__text_size + 5 + self.manager.get_screen("Showcase").ids.upcoming_songs.font_size = self.__text_size - 5 self.__config = cvr.importing("./data/config.csv").pop(0) + self.__config.pop(1) 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.__songlinfo = self.__info.pop(0) + self.__songpos = self.backfeed.value + self.__songdisplay = int(self.__songpos / float(self.__songlinfo.pop(0)) * 100) + self.manager.get_screen("Showcase").ids.progressbars.value = self.__songdisplay self.__current = self.__upcoming.pop(self.__currents) if self.__config == ["1"]: self.ids.current_song.text = self.__current[:(len(self.__current) - 4)] @@ -217,8 +234,8 @@ 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.theme_cls.primary_palette = "Blue" + self.theme_cls.accent_palette = "Gray" # self.icon = "./BiogasControllerAppLogo.png" return Builder.load_file("./bin/gui/gui.kv")