system.vision.playSoundClip
Backwards Compatibility
This function replaces system.util.playSoundClip. Any scripts containing Vision Client scoped functions that were replaced with system.vision syntax will still work to maintain backwards compatibility. Only the system.vision variations will appear in the Script Editor's autocomplete popup.
This function is used in Python Scripting.
Description​
Plays a sound clip from a .wav file to the system's default audio device. The .wav file can be specified as a filepath, a URL, or directly as a raw List[Byte].
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax - Using a Byte List​
system.vision.playSoundClip(wavBytes, [volume], [wait])
Parameters​
Type | Parameter | Description |
---|---|---|
List[Byte] | wavBytes | A byte list of a wav file. |
Float | volume | The clip's volume, represented as a floating point number between 0.0 and 1.0. [optional] |
Boolean | wait | A boolean flag indicating whether or not the call to playSoundClip should block further script execution within the triggering event until the clip finishes. Useful in cases where code on lines after the playSoundClip call should wait until the sound clip finishes playing. [optional] |
Returns​
Nothing
Scope​
Vision Client
Syntax - Using a Filepath or URL​
system.vision.playSoundClip(wavFile [, volume] [, wait])
Parameters​
Type | Parameter | Description |
---|---|---|
String | wavFile | A filepath or URL that represents a wav file. |
Float | volume | The clip's volume, represented as a floating point number between 0.0 and 1.0. [optional] |
Boolean | wait | A boolean flag indicating whether or not the call to playSoundClip should block further script execution within the triggering event until the clip finishes. Useful in cases where code on lines after the playSoundClip call should wait until the sound clip finishes playing. [optional] |
Returns​
Nothing
Scope​
Vision Client
Code Examples​
Example #1
# This code would play a sound clip at full volume that was located on the current
# host's filesystem. It will not return until the clip in finished playing.
system.vision.playSoundClip("C:\\sounds\\siren.wav")
Example #2
# This code would pull a sound clip out of a BLOB field from a database,
# playing it asynchronously at half volume.
query = "SELECT wavBlob FROM sounds WHERE type='alert_high'"
soundData = system.db.runScalarQuery(query)
system.vision.playSoundClip(soundData, 0.5, 0)