Availability: Windows.
New in version 1.5.2.
The winsound module provides access to the basic sound-playing machinery provided by Windows platforms. It includes two functions and several constants.
| frequency, duration) |
| sound, flags) |
None. Its interpretation depends on the
value of flags, which can be a bit-wise ORed combination of
the constants described below. If the system indicates an error,
RuntimeError is raised.
[type=MB_OK]) |
-1, MB_ICONASTERISK, MB_ICONEXCLAMATION,
MB_ICONHAND, MB_ICONQUESTION, and MB_OK, all
described below. The value -1 produces a ``simple beep'';
this is the final fallback if a sound cannot be played otherwise.
New in version 2.3.
All Win32 systems support at least the following; most systems support many more:
| PlaySound() name | Corresponding Control Panel Sound name |
|---|---|
'SystemAsterisk' |
Asterisk |
'SystemExclamation' |
Exclamation |
'SystemExit' |
Exit Windows |
'SystemHand' |
Critical Stop |
'SystemQuestion' |
Question |
For example:
import winsound
# Play Windows exit sound.
winsound.PlaySound("SystemExit", winsound.SND_ALIAS)
# Probably play Windows default sound, if any is registered (because
# "*" probably isn't the registered name of any sound).
winsound.PlaySound("*", winsound.SND_ALIAS)
Note: This module does not support playing from a memory image asynchronously, so a combination of this flag and SND_ASYNC will raise RuntimeError.
SystemDefault sound.
SystemExclamation sound.
SystemHand sound.
SystemQuestion sound.
SystemDefault sound.
See About this document... for information on suggesting changes.