finished base version 1.0 and as such the app is fully functional though there might still be bugs around and also some improvements will be made later on

This commit is contained in:
janis
2022-03-10 22:50:29 +01:00
parent 8bb93c3957
commit 17b2bb1fa2
9 changed files with 503 additions and 12 deletions

96
bin/player.py Normal file
View File

@@ -0,0 +1,96 @@
import pygame.mixer as mx
import bin.csv_parsers
import copy
import bin.filepathanalysis
import pygame
import time
pa = bin.filepathanalysis.PathAnalysis()
cvr = bin.csv_parsers.CsvRead()
cvw = bin.csv_parsers.CsvWrite()
class Player:
def __init__(self):
self.__running = 1
self.event = ""
self.__recent_change = 1000000
self.__imports = []
self.information = []
self.current_playing_pos = 0
def start_playing(self):
# initialize playing
if pygame.get_init() == True:
pass
else:
pygame.init()
self.path = cvr.importing("./data/temp.csv").pop(0)
self.__imports = pa.validsonglistcreator(self.path.pop())
self.playlist = self.__imports.pop(0)
self.playlist_backup = copy.deepcopy(self.playlist)
self.information = self.__imports.pop(0)
mx.init()
self.current_playing = self.playlist.pop(0)
mx.music.load(self.current_playing)
mx.music.play()
mx.music.pause()
def infoupdater(self):
self.transmission = []
cvw.write_str("./data/songtemp.csv", [self.current_playing_pos])
cvw.app_str("./data/songtemp.csv", self.information)
def musicmanager(self, inst, other):
self.start_playing()
self.infoupdater()
while self.__running == 1:
if self.__recent_change < 1:
pass
else:
self.__recent_change -= 1
# instructions from main class
if other.value == 1:
other.value = 0
mx.music.unload()
if len(self.playlist) > 0:
pass
else:
self.playlist = copy.deepcopy(self.playlist_backup)
self.current_playing_pos = -1
self.current_playing = self.playlist.pop(0)
self.current_playing_pos += 1
mx.music.load(self.current_playing)
mx.music.play()
self.__recent_change = 1000000
self.infoupdater()
elif other.value == 2:
mx.music.rewind()
other.value = 0
elif other.value == 3:
self.__recent_change = 1000000
other.value = 0
else:
if inst.value == 1:
mx.music.unpause()
else:
mx.music.pause()
# Main event-checking part
if mx.music.get_busy() is False and inst.value == 1 and self.__recent_change == 0:
mx.music.unload()
if len(self.playlist) > 0:
pass
else:
self.playlist = copy.deepcopy(self.playlist_backup)
self.current_playing_pos = -1
self.current_playing = self.playlist.pop(0)
self.current_playing_pos += 1
mx.music.load(self.current_playing)
mx.music.play()
self.__recent_change = 10000000
self.infoupdater()
else:
pass