Plays a sound, video, or other supported file type.
SoundPlay Filename , Wait
The name of the file to be played, which is assumed to be in A_WorkingDir if an absolute path isn't specified.
To produce standard system sounds, specify an asterisk followed by a number as shown below. Note: the Wait parameter has no effect in this mode.
*-1: Simple beep. If the sound card is not available, the sound is generated using the speaker.
*16: Hand (stop/error)
*64: Asterisk (info)
Known limitation: Due to a quirk in Windows, WAV files with a path longer than 127 characters will not be played. To work around this, use other file types such as MP3 (with a path length of up to 255 characters) or use 8.3 short paths (see A_LoopFileShortPath how to retrieve such paths).
Type: String or Integer (boolean)
If omitted, the script's current thread will move on to the next statement(s) while the file is playing. To avoid this, specify 1 or the word WAIT, which causes the current thread to wait until the file is finished playing before continuing. Even while waiting, new threads can be launched via hotkey, custom menu item, or timer.
Known limitation: If the WAIT parameter is omitted, the OS might consider the playing file to be "in use" until the script closes or until another file is played (even a nonexistent file).
An exception is thrown on failure.
All Windows OSes should be able to play .wav files. However, other files (.mp3, .avi, etc.) might not be playable if the right codecs or features aren't installed on the OS.
If a file is playing and the current script plays a second file, the first file will be stopped so that the second one can play. On some systems, certain file types might stop playing even when an entirely separate script plays a new file.
To stop a file that is currently playing, use SoundPlay on a nonexistent filename as in this example:
If the script is exited, any currently-playing file that it started will stop.
SoundBeep, Sound Functions, MsgBox, Threads
SoundPlay A_WinDir "\Media\ding.wav" SoundPlay "*-1" ; Simple beep. If the sound card is not available, the sound is generated using the speaker.