Can't stop simpleaudio music using functions

125 Views Asked by At

So basically, I'm making a GUI that allows you to play music, I made a button that is supposed to destroy itself and stop music, but it only seems to destroy itself and the music keeps playing, no errors, no nothing.

Code (Im only going to include the part with the problem):

# Function to stop music
def stopMusic():
    play_obj.stop
    stop.destroy()

# Converting mp3 files to wav files to play
src = r'C:\Users\User\Downloads\Sportify\MP3\Blinding Lights.mp3'
dst = r'C:\Users\User\Downloads\Sportify\Wav\Blinding Lights.wav'
sound = AudioSegment.from_mp3(src)
sound.export(dst, format="wav")

# Playing music
filename = r'C:\Users\User\Downloads\Sportify\Wav\Blinding Lights.wav'
wave_obj = sa.WaveObject.from_wave_file(filename)
play_obj = wave_obj.play()

# Making the gui button
frame = Frame()
frame.pack(side=BOTTOM)
stop = Button(frame, text='Stop Music', command=stopMusic, font="verdana")
stop.pack(side=BOTTOM)

Please help me fix this problem, I've been searching google for 20 minutes now, thanks!

0

There are 0 best solutions below