Sound
From Xojo Documentation
Used to play sounds.
Properties | ||
|
Methods | |||||
|
Shared Methods | |
|
Notes
Sounds that have been added to the project can be accessed via their object name. Sounds can also be loaded from disk by calling the Open method of a Sound.
Sound can play sound formats and simultaneous sounds as determined by the system.
On Windows, Sound can play a variety of sound formats but can only play WAV sounds simultaneously.
On Linux, Sound uses GStreamer (requires version 0.10+) by default, which supports a wide range of sound formats. Xine is used when GStreamer is not available.
On macOS, AVFoundation is used to play sounds with support for a wide variety of sound formats.
Examples
This code plays a sound called "SledgeHammer" which has been added to the project:
This code loads a sound file called "TaDa.mp3" from the desktop into a sound object and plays it.
If f.Exists Then
Try
Var s As Sound = s.Open(f)
s.Play
Catch error As IOException
MessageBox("The sound file could not be opened. Error: " + error.Message)
End Try
End If
The following code plays the sound "Giggle", which has been added to the project, in an endless loop.
This code stops "Giggle".
See Also
NotePlayer control.