0
I’m set up a system that uses Pygame tools, in other terms, I’m creating an application that runs songs, I’ve been trying to make that, with the current music ending (stored in one vector), the music jumps to the other index, so it is not necessary to keep pressing Next always
I’ve tried to create a loop While
using the method mixer.music.get_busy()
, which returns True
when the song is being performed and False
otherwise then I could advance an index as soon as the song stops, but in fact Loop keeps running finitely times until the end of the song, causing a bug and crashing the system, I have tried using the method mixer.music.queue()
, which passes a song when the previous one finishes playing, but still generates error.
I’ll be leaving down part 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’d be grateful.
Managed to solve this problem?
– Daniel
@Blogger - negative
– Félix
Can make a mcve?
– Daniel
@Blogger I don’t know much about
– Félix
The idea of mcve is to have a complete code that can be executed to demonstrate the problem. You can reproduce your problem in a new code?
– Daniel