This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GUIcomposer - playing sound file

Any ideas how to play a sound file when a bound variable changes from 0 to 1 or when getting 100% in the progress bar (for example)?

If you can put an example code, that would be highly appreciated.

Thank you.

  • Hi Ran,

    Add this to the app.js file,

    require(["dojo/ready"], function(ready){
      ready(function(){
        // logic that requires that Dojo is fully initialized should go here

        var textBox = dijit.byId("myId");
        textBox.watch("value", checkValue);
      });
    });

    function checkValue() {
      var textBox = dijit.byId("myId")
      var value = textBox.get("value");
      if (value === "9") {
        document.getElementById("dummy").innerHTML = "<audio autoplay='true'> <source src='http://people.sc.fsu.edu/~jburkardt/data/wav/thermo.wav' type='audio/wav' /> </audio>";
      }
    }


    and this to the body of the html file,

    <span id="dummy"></span>

    Bind a textbox to a target value and give it a widget id "myId", the widget id must match the id in the app.js file. When the target variable equals to 9, the wav file from the link above will play.

    Regards,
    Patrick