Development Topics > Miscellaneous Topics > GUI Extensions

Playing a Sound File

You can use the technique just discussed above to launch the sound player which has been associated with the extension of the sound or WAV file you want to play, but this may have the undesirable side effect of leaving the sound player application open. To play a sound file directly, without launching or displaying any additional application, you can use the following. See the MIAMEX sample program for a code example.

xcall MIAMEX, MX_PLAYSOUND, soundspec, status, flags

Parameters

soundspec

Specification of the sound file (AMOS or native format)

status  (F,6)

Code which returns 0 for failure, else success.

flags

Numeric code containing the sum of zero or more of the following options to control how the sound file is played:

Flags

Description

1

Return immediately (while sound still playing.) To terminate the sound later, call with Soundspec=””

8

Play sound continuously. Must be used with option 1 (1+8=9); terminate with another call (using another Soundspec or Soundspec=””).

16

Don’t stop a currently playing sound. (Otherwise the currently playing sound is interrupted by the new one.)

65536

Soundspec is not a file but the name of an “eventlabel” defined in the Registry. (See HKEY_USERS\.DEFAULT\AppEvents\EventLabels in the Registry.) Example eventlabels would be “SystemAsterisk” or “NMain-MouseClick”.