Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Play sounds asynchronously, but let the function wait. #29
Currently, wait can be populated (defaults to False)
If it's False, the SND_ASYNC property is set - causing the sound to play in the background and the GUI to return straight away.
Should always call with SND_ASYNC, however if wait=True, then start an after loop to keep going until the sound finishes: http://effbot.org/tkinterbook/widget.htm#Tkinter.Widget.after-method
Not sure how to determine if sound is finished...
SND_NOWAIT might have done it, but is no longer supported
pushed a commit
Sep 26, 2016
So, we'll play the sound in a thread - with no wait, and use after to keep checking if it's finished (the thread will be dead).
Once the sound finishes we then call the registered function.
I want to push this model, rather than trying to make the code block, to force better code organisation.
The new threading model somewhat supports this.
Will play the sound in a separate thread, and only when the sound finishes, will the
winsound no longer supports the SNDPURGE & NOWAIT flags, so it's hard to have appJar deal well with this situation.
PLAY & STOP work well.
Running ASYNC tunes in a thread, with/without a callback works fine - with caveats:
I'm OK with all of the above. So will update the docs, and close this issue.