Velocity API: Device.beep()

Version 2

    Return To Index

    Device.beep()

    Overview

    Plays a tone through the speaker of the mobile device.

    Use Cases

    • You want to play a custom beep with your script.
    • You want to override the default beeps using WLEvent.on(“Beep”, …); and play custom beep(s) instead.

    Remarks

    Calls to Device.beep() are asynchronous and added to a beep queue, meaning that this call will immediately return.

    Format

     

    Device.beep(frequency, durationMilliseconds, trailingSilence);
    ParameterDescriptionTypeRequiredNotes
    frequencyTone frequency in hertz.NumberRequiredInteger between 100 and 2000
    durationMillisecondsDuration of the tone in milliseconds, where 1000 milliseconds is equal to 1 second.NumberRequiredInteger between 1 and 100000
    trailingSilenceAmount of time in milliseconds that no tone should be played.NumberRequiredInteger between 0 and 100000

     

    Example 1

    /* The device will beep for a duration of 500 milliseconds 
    * with a 50 millisecond trailing silence.
    */
      
    Device.beep(200,500,50);

    Example 2

    /* The scan beep is replaced with a tada.wav. */     
    WLEvent.on("Beep", function (event) {
         if(event.type == "3")
         {
         Device.beepPlayFile("tada.wav");
         event.eventHandled = true;
         }
    });