There are a number of ways to play sound via TouchControl. A couple of the easiest are:
1. Add an audio file (.mp3, .wav, etc.) to the "html" folder under your TouchControl server data directory. Then create a Script button with the following Javascript:
new Audio(‘html/my_audio_file.mp3’).play();
2. Create a script button with the following script:
var audioCtx = new window.webkitAudioContext;
function beep(duration, frequency, volume, type, callback) {
var oscillator = audioCtx.createOscillator();
var gainNode = audioCtx.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioCtx.destination);
if (volume){gainNode.gain.value = volume;};
if (frequency){oscillator.frequency.value = frequency;}
if (type){oscillator.type = type;}
if (callback){oscillator.onended = callback;}
oscillator.start();
setTimeout(function(){oscillator.stop()}, (duration ? duration : 500));
};
beep();
Make sure you don’t have your device muted!