From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from Object)

Used to play sounds.

Pan Volume

Clone IsPlaying PlayLooping
Handle Play Stop
Shared Methods


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.


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.

Var soundFile As FolderItem = SpecialFolder.Desktop.Child("TaDa.mp3")
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)
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

DesktopNotePlayer control.