Sounds in Mobile App

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
negley
Profound User
Posts: 45
Joined: Tue Mar 11, 2014 2:50 pm
First Name: William
Last Name: Negley
Company Name: Utz Quality Foods
Contact:

Sounds in Mobile App

Post 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?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Sounds in Mobile App

Post 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.
negley
Profound User
Posts: 45
Joined: Tue Mar 11, 2014 2:50 pm
First Name: William
Last Name: Negley
Company Name: Utz Quality Foods
Contact:

Re: Sounds in Mobile App

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests