Skip navigation
Currently Being Moderated

How to play a sound in JQuery Mobile

May 21, 2013 5:23 AM

This has been driving me nuts for a couple of weeks now - off and on.....it should be very straightforward but I can't get it to work. This is my first attempt at writing an app so I must be missing something blindingly obvious.

 

I'm trying to build an app for smartphones, when the user taps a button on the screen it will play a short sound file maybe 2 - 5 seconds long, sounds easy right? I think all I need is a button and an onclick event (although I read somewhere it's better to use touch-start as onclick has a 3/10 second delay built in). So, I think all I need is javascript to play the soundfile. I understand I have to allow for ogg format as well as mp3 - is that true? My target users could be using droid phones, iphones or windows phones or......so does anyone have a js function that will do whatever is needed to just play a short sound file without a delay?

 

In a related question, what are people using to convert the webapp to a smartphone app? Is it better to use phonegap build or install phonegap on my PC. I've tried both and can't get either to work so I'm using appsgeyser.com which is very straightforward and at least builds a droid app I can see and play with. The problem there was that I can play the sound on my PC (although there is a delay that is too long but probably caused by internet access that I hope will go away when running a smartphone app as everything will be local)  but the smartphone doesn't make a sound at all, the button changes color but no sound comes out. I will be so happy when I hear that first sound come from my phone...sigh.

 

Thanks for any direction you can provide, this is all new to me so I'm still floundering around even to understand what the problem really is..

 

Tony

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points