PlaySound

Definition:

PlaySound(soundfile[, duration[, plays]])

 

Description:

Play an audio file.

 

Platforms:

All

 

Parameters:

soundfile - required

Resource File Name or ID of the file to play.

 

duration - optional

The length of time in milliseconds to play the sound for. Specify 0 (zero) to play the whole file. Alternatively specify a value >0 to play only a part of the file. Default = 0.

Note that if the length of time specified here is greater than that required to play the whole file and the plays parameter below is set to play the file more than once, each pass involves playing the file once and then allowing the remainder of the time specified to elapse before replaying the file.

 

plays - optional

The number of times to play the file, or that part of it specified by the duration parameter above. For example, to play the file once, specify 1, to play it twice, specify 2 etc. If set to 0 (zero), the file will not be played. Default = 1.

 

Returns:

nothing

 

Notes:

  • The audio file must be a file type supported by your device. We suggest you use a .mp3 file. Other audio files may work but you will need to experiment with your particular device to determine which file types are suitable.

  • The file must first be imported into your Project before it can be referred to here. The soundfile parameter can reference the file using its Resource ID or file name. The Resource ID is the name of the sound file as it appears in the App Studio's Resources Pane tree view, e.g. ID_SOUND_MYTUNE_1. You can find the Resource File Name by selecting the sound within the Resources Pane and then looking in the panel at the bottom of the pane.

  • Your Script does not pause whilst the sound is played (even if you specify multiple plays).

  • If you want to include the plays parameter you must also include the duration parameter.