Python Forum

Full Version: Shutdown any audio command
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys i have been absent for a while do to house changing. I'm back now, trying to finish my python program. This are two audio commands in my program. When the audio starts some of them take a while to terminate. So i was thinking to create an "emergency button" to terminate any running audio. Both for playsound or pygame. How can i do that. The button is already created, just have no ideia what command to apply (the program itself is not to be terminated, just any playing sounds)

def nenebot_en():
        thread_pool_executor = futures.ThreadPoolExecutor(max_workers=1)

        def playmp3(file):
                playsound(file)
 
 
        file = 'nenebot_info_en.mp3'
        thread_pool_executor.submit(playmp3, file)
pygame.init()
        pygame.mixer.init()
        pygame.mixer.music.load("erro_pt.mp3")
        pygame.mixer.music.play(0)
        time.sleep(2)
        pygame.mixer.music.load("error_en.mp3")
        pygame.mixer.music.play(0)
        time.sleep(2)
        pygame.mixer.quit()
Well, no administrator available, no one else, can answer this. Congrats all
It is difficult to help you,
if you only publish part of your code.
The best a minimal runable script with your issue.