views:

52

answers:

0

I've added a couple of additional virtual keyboard keys to my page to let the user type characters not found on the iPad's virtual keyboard. They look almost identical to keys on the iPad's keyboard, and inject the character correctly into the INPUT element. But the little (512 bytes) clicking sound .WAV that I'm playing when the user touches one of these keys has some issues.

The first time the user touches one of my keys there's a lag of about two (2) seconds before the sound is played. Subsequent taps on my keys cause the sound to be played instantaneously. However, if the user touches the actual iPad virtual keyboard again, there's a lag before its sound is made, and then if the user returns to my keys, their first-touch-lag returns too.

It doesn't appear as though the iPad can switch back and forth between sound objects very quickly, though maybe there's a setting that would improve this? Or another way of playing the sound? Are different audio formats slower than others?

Second problem, the WAV is too loud. I've been trying to set the volume attribute in javascript in various ways, without success. See

  http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom-media-volume

Has this been implemented?

Here is how the element is declared:

 <audio id='keyclick' src="/media/click.wav" autobuffer="true" type="audio/wav" >

And here is how it's being played:

 var mySound = document.getElementById('keyclick');
  mySound.setAttribute("volume",0.1);  // no effect on volume   
  mySound.volume = 0.1; // no effect on volume
  mySound.play();

Thanks