18.2 winsound -- Sound-playing interface for Windows

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 a single function and several constants.

PlaySound (sound, flags)
Call the underlying PlaySound() function from the Platform API. The sound parameter may be a filename, audio data as a string, or 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.

SND_FILENAME
The sound parameter is the name of a WAV file.

SND_ALIAS
The sound parameter should be interpreted as a control panel sound association name.

SND_LOOP
Play the sound repeatedly. The SND_ASYNC flag must also be used to avoid blocking.

SND_MEMORY
The sound parameter to PlaySound() is a memory image of a WAV file.

Note: This module does not support playing from a memory image asynchonously, so a combination of this flag and SND_ASYNC will raise a RuntimeError.

SND_PURGE
Stop playing all instances of the specified sound.

SND_ASYNC
Return immediately, allowing sounds to play asynchronously.

SND_NODEFAULT
If the specified sound cannot be found, do not play a default beep.

SND_NOSTOP
Do not interrupt sounds currently playing.

SND_NOWAIT
Return immediately if the sound driver is busy.


Send comments on this document to python-docs@python.org.