From Xojo Documentation

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

Sound.Open(file As FolderItem) As Sound

New in 2019r2

Supported for all project types and targets.

Opens the FolderItem to be read and returns its contents as a sound object.


On macOS, the Sound class recognizes sound formats that Core Audio can play.

The Open method is not support for iOS.

On Windows WAVs, WMAs, MP3s, and MIDI files can be played, but only WAVs play with DirectSound (this allows individual pan and volume settings for each sound. You can also play multiple sounds simultaneously).

On Linux GStreamer, xine, or libsndfile is used (in that order if available). Nil is returned if the sound can't be read or isn't a sound file at all.


This example loads a sound file called “hello.mp3” from the desktop into a Sound object and plays it.

Var f As FolderItem = SpecialFolder.Desktop.Child("hello.mp3")
If f <> Nil And f.Exists Then
Var s As Sound
s = s.Open(f)
End If