PyGame-mixer.musician()
I am set up a system that uses the tools of PyGame, in other terms, I am creating an application that runs songs, I am long, trying to make that, with the end of the current song (stored in a vector), the song jumps to the other index, so it is not necessary to keep pressing next always
I have already tried to create a loop While
using the method mixer.music.get_busy()
, which returns True
when the song is playing and False
if otherwise, then I could advance an indicie as soon as the song stops, but in fact The Loop is running finite times until the end of the song, causing a bug and crashing the system, I have tried to use the method mixer.music.queue()
, which passes a song when the previous ends playing, but still generates error.
I will be dropping down some of the source code, so you can have a better understanding of what I'm saying.
def escolherDiretorio (self):
diretorio = askdirectory()
os.chdir(diretorio)
for item in os.listdir():
#print(item)
if item.endswith(".mp3"):
real = os.path.realpath(item)
musicas.append(item)
self.musica_atual = mixer.init()
self.musica_atual = mixer.music.load(musicas[0])
self.musica_atual = mixer.music.play()
def play (self):
self.musica_atual = mixer.music.play()
def stop (self):
self.musica_atual = mixer.music.stop()
def nextM (self):
global index
index += 1
self.musica_atual = mixer.music.load(musicas[index])
self.musica_atual = mixer.music.play()
def back (self):
global index
index -= 1
self.musica_atual = mixer.music.load(musicas[index])
self.musica_atual = mixer.music.play()
If you can help me, I will be grateful.