Page 1 of 1

Sounds in Mobile App

Posted: Tue May 27, 2014 1:46 pm
by negley
I am working on a scanning project on a mobile android platform. Their is a audible beep when a bar code is scanned. I would like to add a sound onto the mobile app so when the page appears, a confirmation beep would go off. I was thinking a onload javascript function with a <audio> tag would do the trick, but it does not make a sound. Any help?

Re: Sounds in Mobile App

Posted: Tue May 27, 2014 3:25 pm
by Scott Klement
hi there,

Are you creating a mobile app with PhoneGap? Or, using our Profound UI mobile client app (which is also PhoneGap, but is using code that we wrote)? Or running this in a browser?

One possible issue if you are using PhoneGap or our client is that the URLs for the audio files will need to be relative to the directory of the mobile device you're launching from. (This would not be an issue in a browser.) Profound UI has an API that you can call to fix this called pui.normalizeURL()... details found here:
http://www.profoundlogic.com/docs/displ ... 28+url+%29

The other possibility might be that Android doesn't support the <audio> tag yet. I'm not sure about this as I'm really not an android guy, but I did find some info when searching:
http://stackoverflow.com/questions/2163 ... -use-media

The workaround here would be to call the PhoneGap API to play an audio file.

Re: Sounds in Mobile App

Posted: Tue May 27, 2014 4:21 pm
by negley
I am utilize the Profound UI Mobile client app.

I used the normalizeURL() API and it works great!

Anyone else who is looking to add sounds to mobile apps:

Create a HTMLContainer on the Screen

Add code to Onload on the Screen w/HTMLContainer

Code: Select all

//Get the on screen HTML Container 
var htmlBox = getObj('HtmlContainer1');
//Normalize the sound path
var source = pui.normalizeURL("/profoundui/proddata/sounds/sample1.wav")
//Set the inner html of the placed container to a Audio tag with the SRC of the Source variable
htmlBox.innerHTML = '<audio controls autoplay><source src="'+source+'" type="audio/mpeg"></audio>';
Works with WAV and MP3.