Skip to content Skip to sidebar Skip to footer

Play A Sound Using Python Subprocess And Threading

I am trying to open an alert, then loop a sound until the alert is closed. Then the sound should stop. I tried this: import threading import time import subprocess stop_sound = F

Solution 1:

It's because process.poll() returns 0 after the process finishes, which is a falsy value.

Quick fix:

while not stop_sound:
    if process.poll() is not None:
        break

Post a Comment for "Play A Sound Using Python Subprocess And Threading"