Python GUI with Tkinter - Pause and Unpause the music using Tkinter and Pygame - 12/30

preview_player
Показать описание
Day 12 - In this video we learn to pause and unpause the audio using Pygame's mixer class.

#tkinter #python #tkinter30
Рекомендации по теме
Комментарии
Автор

Engineering student, needed that self care story at the beginning haha

natureabioros
Автор

# Some simplification in pausing logic using if

def play_music():
global paused_status # We initialize pause_status to False inside root()

if paused_status:
paused_status = False
mixer.music.unpause() # Pause playing music
else:
Poppy - Lowlife - YouTube (720p).mp3')
mixer.music.play() # Playing music

def pause_music():
global paused_status
paused_status = True
mixer.music.pause()

def quit():
mixer.music.stop() #stop playing music
global root
root.destroy()

def set_volume(vol):
# Changes volume of music played

root = Tk()


mixer.init()
paused_status = False

play_button = Button(root, text='play', command=play_music)
play_button.pack()

pause_button = Button(root, text='pause', command=pause_music)
pause_button.pack()

stop_button = Button(root, text='stop', command=mixer.music.stop)
stop_button.pack()

volume = Scale(root,
from_=0,
to=100,
orient='horizontal',
command=set_volume)
volume.pack()
volume.set(70)
set_volume(70)

root.protocol('WM_DELETE_WINDOW', quit)
root.mainloop()

pran
Автор

While the music is paused, when clicked on stop it stops the music. Later when tried to play it, it doesn't play

rohitv
Автор

Hello Sir, can we use mixer.get_init() method to check whether the music has been paused or not (i.e) we are checking that the music is already loaded or not so that we can unpause if the music is already loaded else we can load and play the music from start using the same play button. This worked for me and i need your opinion whether we can use this or not. Thank you Sir

avinashm
Автор

how can you creat file 'journy.wav' with ? in file, it is not work well with me>>>>plz answer me

أقدمفيدوهاتشيقةورائعة
Автор

Please teach how to combine play and pause button 😄

tks
Автор

Hi, I think there is a wrong logic, because when you press stop button the play button won"t work again.
i solved it by creating a new module with global paused variable inside and then call that variable inside main program
please check. Best Regards

modarzeneh
Автор

Hey Vindaloo, is it possible you could hire some schlob in the U.S. who is not working to speak in your videos for you? Your accent is flat out killen me bro.

scott
Автор

why are you soo confusing to your views
unpause music logic is very very simple
here is code:
def unpause():
    mixer.music.unpause()



unpausebtn = Button(root,  image=stop_photo,  command=unpause)
unpausebtn.pack()

Master-qreq