1

I'm using the winsound library to play a file asynchronously. However, I would like to know when the sound is done playing. If the sound is done, then I keep the flag set to 1. Otherwise, I set flag to 0.

This is my current code:

import winsound

winsound.PlaySound('c:\\audiocheck.net_whitenoise.wav',winsound.SND_ALIAS | winsound.SND_ASYNC)
flag = 1
print(flag)
ndmeiri
  • 4,979
  • 12
  • 37
  • 45

1 Answers1

-1
import winsound
import time

start = time.time()
winsound.PlaySound('c:\\audiocheck.net_whitenoise.wav',winsound.SND_ALIAS | winsound.SND_ASYNC)
flag = 1
while flag == 1:
    elapsed = time.time() - start
    if elapsed >= 10:
        flag = 0
ndmeiri
  • 4,979
  • 12
  • 37
  • 45