This class represents a short sound (loaded from Windows WAV
file), that can be stored in memory and played.
Currently this class is implemented on Windows and Unix and can use either Open Sound System (OSS
) or Simple DirectMedia Layer (SDL
) under the latter. Notice that OSS
is not provided any more by most, and maybe even all, Linux systems in 2017 and osspd (OSS
Proxy Daemon) package typically needs to be installed to make it work.
Default constructor. |
|
Constructs a wave object from a file or resource. |
|
Create a sound object from data in a memory buffer in |
|
Returns |
|
Plays the sound file. |
|
Plays the sound file. |
|
If a sound is played, this function stops it. |
|
wx.adv.
Sound
(Object)¶Possible constructors:
Sound()
Sound(fileName)
This class represents a short sound (loaded from Windows WAV
file),
that can be stored in memory and played.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__init__ (self, fileName)
Constructs a wave object from a file or, under Windows, from a Windows resource.
Call IsOk
to determine whether this succeeded.
fileName (string) – The filename or Windows resource.
Create
(self, fileName)¶Constructs a wave object from a file or resource.
fileName (string) – The filename or Windows resource.
bool
True
if the call was successful, False
otherwise.
CreateFromData
(self, data)¶Create a sound object from data in a memory buffer in WAV
format.
bool
IsOk
(self)¶Returns True
if the object contains a successfully loaded file or resource, False
otherwise.
bool
Play
(self, flags=SOUND_ASYNC)¶Plays the sound file.
If another sound is playing, it will be interrupted.
Returns True
on success, False
otherwise. Note that in general it is possible to delete the object which is being asynchronously played any time after calling this function and the sound would continue playing, however this currently doesn’t work under Windows for sound objects loaded from memory data.
The possible values for flags are:
wx.adv.SOUND_SYNC
: Play
will block and wait until the sound is replayed.
wx.adv.SOUND_ASYNC
: Sound is played asynchronously, Play
returns immediately.
SOUND_ASYNC|wxSOUND_LOOP: Sound is played asynchronously and loops until another sound is played, Stop
is called or the program terminates.
The static form is shorthand for this code:
wx.adv.Sound(filename).Play(flags)
flags –
bool
PlaySound
(filename, flags=SOUND_ASYNC)¶Plays the sound file.
If another sound is playing, it will be interrupted.
Returns True
on success, False
otherwise. Note that in general it is possible to delete the object which is being asynchronously played any time after calling this function and the sound would continue playing, however this currently doesn’t work under Windows for sound objects loaded from memory data.
The possible values for flags are:
wx.adv.SOUND_SYNC
: Play
will block and wait until the sound is replayed.
wx.adv.SOUND_ASYNC
: Sound is played asynchronously, Play
returns immediately.
SOUND_ASYNC|wxSOUND_LOOP: Sound is played asynchronously and loops until another sound is played, Stop
is called or the program terminates.
The static form is shorthand for this code:
wx.adv.Sound(filename).Play(flags)
filename (string) –
flags –
bool
Stop
()¶If a sound is played, this function stops it.
__bool__
(self)¶int
__nonzero__
(self)¶int