Difference between revisions of "Sound"
From Xojo Documentation
|Line 67:||Line 67:|
Latest revision as of 22:19, 5 October 2021
Used to play sounds.
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 macOS, AVFoundation is used to play sounds with support for a wide variety of sound formats.
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 soundFile.Exists Then
Var tada As Sound = Sound.Open(soundFile)
Catch error As IOException
MessageBox("The sound file could not be opened. Error: " + error.Message)
The following code plays the sound "Giggle", which has been added to the project, in an endless loop.
This code stops "Giggle".