Audio Alerts

Overview

The audio-alert setting plays an audio file in the user's browser when an alert-expression evaluates to true.

alert-expression = value > 70
audio-alert = siren.mp3

Audio is played each time when the result of the alert-expression expression changes from false to true or from true to false.

Browser Settings

  • Firefox: media.autoplay.enabled set to true.
  • Chrome: chrome://flags/#autoplay-policyset to No user gesture is required.

Supported Audio Codecs

Browser mp3 wav ogg
Chrome Yes Yes Yes
Firefox Yes Yes Yes
Safari Yes Yes No
Internet Explorer Yes No No

Test

To test if your browser supports auto-playback, open this example.

Scope

  • audio-alert setting is supported in widgets that load series data.
  • audio-alert setting is not supported by the Alert Table, Property Table, Page, and Map widgets. For an alternative, refer to this example which plays audio upon alert in the Alert Table.

File Path

The path to the audio file can be specified as an absolute or relative path.

Relative path must start with /portal/resource/ and the file must be present in the /opt/atsd/atsd/conf/portal directory on the target ATSD server.

Mapping example:

/portal/resource/alarm.ogg -> /opt/atsd/atsd/conf/portal/alarm.ogg

Sample Sounds

Download the following sample mp3 files to the /opt/atsd/atsd/conf/portal directory on the ATSD server.

Refer to files as /portal/resource/name-to-file.mp3.

alert-expression = value > 50
audio-alert = /portal/resource/alarm.mp3

Alert Expressions

Alert on false -> true

alert-expression = value > 70
audio-alert = /portal/resource/siren.mp3

Alert on false -> true and true -> false

# set alert-expression to 'value' so that it is always true
# choose which file to play using a ternary expression in audio-alert
alert-expression = value
audio-alert = (alert > 0.5) ? 'error.mp3': 'normal.mp3'

Widget Settings

  • The settings apply to the [widget] section.
Name Description
audio-alert Path to audio file played when alert-expression evaluates to true.
Example: audio-alert = /portal/resource/alarm.mp3
audio-onload Play audio on initial widget load if alert-expression is true.
Possible values: false, true.
Default value: false.
Example: audio-onload = true

Examples

Play Audio on Threshold

Play Audio on Alert