Jump to content

Android Chrome: Click sound on every touch


erich.wanker

Recommended Posts

Hy,

short question ..

if i start my UniGui App on Android/ChromeBrowser as a "Progressive Web app" - is it possible to play a sound on every "touch" event ..? .. 

.. so the user experiance is more "App style" ;-)

 

 

Link to comment
Share on other sites

SOLUTION FOUND 

yes - a manually thing would work ;-)

function playAudio() {
  var a = new Audio('files/sound/click.mp3');
  a.play();
}

On the things what should click:  ClientEvent / extEvent : function click(sender, eOpts)  {   playAudio();  }

 

BUT FOR ANDROID:

..i found a solution  :-) for every "touch"

window.addEventListener('touchstart', function playAudio() {
  var a = new Audio('files/sound/click.mp3');
  a.play();
})

Link to comment
Share on other sites

QUESTION:

performance is bad ...

the "var a = new Audio.." is allways creat  a audio-element on every touch-event 

how can i make the click sound FASTER - it takes 0.5 seconds from touch to sound ..

 

a test with following lines makes it NOT better:

<script>

var a = document.createElement('audio');
a.src = 'files/sound/click.ogg';

window.addEventListener('touchstart', function playAudio() {
  a.play();
})

 

 

Link to comment
Share on other sites

  • 2 years later...

good morning mr. erich.wanker,

I have copied your code but I do not know where to place the instruction to reproduce the sound.

My need is to read bar codes compare it with the database, if there is to emit a sound of correct or incorrect which must be issued very fast,

try another method but it is layers to emit 10 times on the mobile, in windows there is no problem.

 It is possible that you give me an aid of what code and / or example I should use to get the sound to be reproduced.  

 

thank you for your collaboration

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...