Platforms: Windows
The winsound module provides access to the basic sound-playing machinery provided by Windows platforms. It includes functions and several constants.
The sound parameter is a sound association name from the registry. If the registry contains no such name, play the system default sound unless SND_NODEFAULT is also specified. If no default sound is registered, raise RuntimeError. Do not use with SND_FILENAME.
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)
The sound parameter to PlaySound() is a memory image of a WAV file, as a string.
Note
This module does not support playing from a memory image asynchronously, so a combination of this flag and SND_ASYNC will raise RuntimeError.
Stop playing all instances of the specified sound.
Note
This flag is not supported on modern Windows platforms.
winreg – Windows registry access
Enter search terms or a module, class or function name.