Skip to main content
Version: Next

PLAY

PLAY ( objectName {; async} )

ParameterTypeDescription
objectNameTextName or path of sound file or system soundEmpty string for stopping asynchronous play
asyncInteger(Windows) If specified, asynchronous execution; If omitted, synchronous execution

This command is not thread-safe, it cannot be used in preemptive code.

Description

The PLAY command plays sound or multimedia files. You pass the full pathname of the file you want to play in objectName. On OS X, the command can also be used to play a system sound.

  • To play a file, pass its name and pathname in objectName. You can pass a full pathname or a pathname relative to the database structure file.
    The main sound and multimedia file formats are supported: .WAV, .MP3, .AIFF (OS X), etc. Under OS X, the command supports more particularly the Core Audio formats.
  • (OS X only) To play a system sound, pass its name directly in the objectName parameter.

Note: 'snd' resources, as used on Mac OS 9 and older, are no longer supported.

The async parameter specifies that the sound will play asynchronously on Windows. Synchronous play means that all processing stops until the sound has finished playing; asynchronous means that processing does not stop and the sound plays in the background. If async is passed and contains 0 (or any longint value), the sound is played asynchronously. If omitted, the sound is played synchronously.
Note: On OS X, the sound is always played asynchronously, with or without the async parameter.

To stop playing an asynchronous sound, use the following statement:

 PLAY("";0)

Example 1

The following example shows how to play a WAV file on Windows:

 $DocRef :=Open document("";"WAV";Read Mode)
 If(OK=1)
    CLOSE DOCUMENT($DocRef)
    PLAY(Document;0) //play asynchronously
 End if

Example 2

The following example code plays a system sound on OS X:

 PLAY("Submarine.aiff")

See also

BEEP