PyGame - mixer.music ()

0
I'm setting up a system that uses PyGame tools, in other words, I'm creating an application that runs songs, I'm a long time trying to do that, with the end of the current song (stored in a vector) the music jumped to the other indicie, so it is not necessary to stay pressing Next always

I have tried to create a While loop using the mixer.music.get_busy() method, which returns True when the song is playing and False otherwise I could advance a prompt as soon as the song stops, but in fact the Loop runs Finite times until the end of the song, causing a bug and crashing the system, I already tried to use the mixer.music.queue() method, which passes a song when the previous one finishes playing, but still generates error. / p>

I'll be dropping down part of the source code, so that 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'll be grateful.

    
asked by anonymous 16.05.2017 / 00:43

0 answers