LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Play sound when button is pressed in WebVI

Solved!
Go to solution

Is it possible to play a sound when a button in WebVI is pressed? 

0 Kudos
Message 1 of 7
(2,661 Views)

Hi,

 

There's no inbuilt node to play a sound/beep. However, there's one way you could add capability to play sound in your webVI.

 

Web Module has a feature called JavaScript Library Interface (JSLI), which lets you call your JavaScript code from a webVI. Using JSLI, you can call your JavaScript function which plays the sound.

 

This page has many simple code snippets which show how to play sound using JavaScript. This page has an example showing how you can make use of JSLI.

Sujay Narayana
Principal Software Engineer
0 Kudos
Message 3 of 7
(2,594 Views)

Sujay, the links you sent are great, thank you! However, I am not an expert in JS (yet...), so I wonder how I need to alter the JS code to use it in my webVI. For example this code (which I found in the link that you sent) http://jsfiddle.net/55Kfu/1506/ . 

0 Kudos
Message 4 of 7
(2,575 Views)

I'm attaching a project which does this. I have modified the example project which I linked above (just so you can compare this with the existing example there), and incorporated the JS which you provided in it.

 

I have added the JavaScript code which makes the beep sound under "Calculator Library.gcomp\javascript". The integration for this JavaScript code is added in the "Calculator Library.gcomp\Calculator Functions.jsli" file. Once I did this, the "Make Beep Sound" node got added to the palette in the diagram palette of webVI.

 

In the attached project, I'm calling the "Make Beep Sound" node in a loop as part of the "WebApp.gcomp\Beep.gviweb" VI. You can run this webVI to see the full thing in action.

Sujay Narayana
Principal Software Engineer
0 Kudos
Message 5 of 7
(2,554 Views)

I get an error about 5 sec after I run the WebVI, do you know the reason? I attached a screenshot. 

 

 

0 Kudos
Message 6 of 7
(2,543 Views)
Solution
Accepted by RoboNuC4

Not sure what the issue was. I'm attaching another simpler JS file which you can replace in the earlier attachment.

Sujay Narayana
Principal Software Engineer
Message 7 of 7
(2,515 Views)