instant Click sound in Web App

As sometimes it takes a Web App a little time before the user can see they have clicked a button,
and some smartphone/tablets users do not press hard enough or swipe more than touch,
I would like to add something in the mouse down event that plays a sound (mp3 or ogg), in such a way that (at least after the first time) it plays instantly.

When I use WebAudioPlayer I can load an MP3, but it takes about 2 seconds before the sound then actually plays.

Is it possible to have the sound played instantly, perhaps using javascript?
A code snippet would be highly appreciated.

It is relatively simple, but there will be a lag between the click and the actual sound.

  • Place a Label1 on the WebPage with nothing as text
  • In a button Action event :

[code] dim js as string = “document.getElementById(’”+Label1.ControlID+"’).innerHTML= "
js = js + “”""" ;"

self.ExecuteJavaScript(js)
[/code]

Sound from http://soundbible.com/tags-click.html

The most difficult will be to find the proper sound. The Internet if full of stupid sites with the strangest sounds, but a very basic click is hard to find. The site I list has a few convincing clicks, but in the end, you may want to record your own.

Here I have linked directly to the resource, but you also could create a webfile.

@Michel Bujardet
Thanks Michel, the lag is however still annoying and the very reason I wanted an instant click sound; sometimes a user clicks twice because they think the click wasn’t registered, but in fact the web App does not instantly refresh the display.
The 300ms delay in iOS adds to the laggy feeling the user gets. But your suggestion is appreciated

Why not show a progress wheel or something and disable the button so it can’t be pressed twice?

[quote=206456:@Boudewijn Krijger]@Michel Bujardet
Thanks Michel, the lag is however still annoying and the very reason I wanted an instant click sound; sometimes a user clicks twice because they think the click wasn’t registered, but in fact the web App does not instantly refresh the display.
The 300ms delay in iOS adds to the laggy feeling the user gets. But your suggestion is appreciated[/quote]

I posted the best I know of. There is no way I know of to have no lag in the current state of web technology.

Until if ever the click is baked into the browser, I doubt you will find any way to obtain what you want through a simple web app. It may be possible to conceive an extension for the browser that does that, but as I can see for Chrome it does not exist yet.

Why not pre-load the sound and invoke it when it’s needed? Then there’s no delay between click, make request to sound file, and play the sound file? HTML5 is awesome :slight_smile:

Try this:

@Matthew Combatti

Thanks for the suggestion Matthew, but it does not work on iOS browsers;

link text

Or at least I think that is why I do hear the sound on my Mac, but not on my iPad/iphone.

Not all devices play a sound, which is why all operating systems use both a visual and audible cue.
Can you change the button color faster?
Or hide it?

From what I could read on SO, Android is just as finicky with sound. I tried the code on the page you link to to no avail.

The most convincing I found is this :
http://pupunzi.open-lab.com/2013/03/13/making-html5-audio-actually-work-on-mobile/

Most important, their demos WORK.