closed
Public

I previously asked about how I might play sound files in a prototype (important if your product or software makes use of audio feedback). Xavier said that they are trying to figure out the best way to support sounds. He also answered that I might try using a hidden iFrame. I’ve tried that from within ForeUI and by editing the index.html and javascript files. Nothing works. I can get a sound to play via an iFrame if I open it in another window (another URL). But I can’t get it to work in the same page. Any ideas, fixes, thoughts?

2 answers

I’ve just submitted an example “Plot: Example for Playing Sound” in the community site.

You can preview it here:
http://www.foreui.net/preview/?file=s…

The main idea is to use an invisible text element to introduce a snippet of HTML code to embed sound playing object, then in the button event handler, invoke the Play() method within the expression of condition branching (it is a hack to invoke any JavaScript).

In the example, the sound file is uploaded to web server beforehand. However you can also specify a local .wav file for sound playing. Just change the src value to “c://file/c:/test.wav” within the invisible text element.

Of course it is a kind of hack instead of official solution, but I believe it works for you 😛

#1
  1. Hi Xavier,
    I'm happy to see that your solution works. And I would love to open the plot you uploaded to the community site. But that file is an XML, and I can't figure out how to open it as a .4ui file. Can you upload a native .4ui file please? Thanks, David Hoard

Hi David, the link above is the DHTML simulation of my plot, and you can download the plot file from the community window in ForeUI (click the “Resource Sharing” button on bottom left corner to open).

Also you can download the .4ui file directly from: http://www.foreui.net/sites/default/f…

#2
  1. Ah, thank you, now I understand. I can see how you're coding in the button. But can I play more that one sound per page? For example, if depending on a certain system state, pressing a button could play one of three possible sounds. How would you do that?
  2. Okay, I figured that one out. Copy and paste the hidden text element and change the ID and sound file URL. For example, change the ID from "sound" to "sound2" in both the hidden text and the button or code that will activate it. Change the sound file URL or file location and it works.
  3. I also figured out how to stop and rewind a sound, so that if you need to play it again, it will start from the beginning. Simply make another button for "Stop", and replace the Play() in the conditional with Stop(). Then copy and paste that conditional in the same button's code. Change that second condition to Rewind().

    I can now finish my project! :-)
  4. That's great :-)

This question is now closed