• Home

  • Download

  • Sharing

  • Instructions

  • Release Notes

  • Solutions

  • FAQ

  • Troubleshooting

  • More

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    Dave
    Nov 02, 2017

    Play Sound

    in TouchControl App

    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!

    0 comments
    0
    Comments

    Share Your ThoughtsSign up to leave a comment.

    0 comments

    © 2010-2020 Touch App Technologies, LLC 

    Privacy Policy