How to insert sounds in a hybrid app?

Asked

Viewed 12 times

-1

Good evening, I’m a beginner in programming and I’m developing a hybrid app. I need to play a specific sound when touching an image of the screen... I’m using bootstrap to layout the application. Any suggestions?

1 answer

1


Good afternoon, yes, it is possible using the HTML audio tag. You need to specify a url, or the path of the file you will play. You can hide the player using display: None. As for playback, you can use a Javascript function in your img tag, where, when you click on the image, a Rigger (trigger) is triggered to play the audio. Follow the example of the audio tag:

 <audio src="caminho_do_arquivo.mp3" style="display: none;" id="id_audio"> 
 </audio>

Together with function js:

 <img class="card-img-top" src="caminho_da_imagem.png" 
  onclick="$('#id_audio').trigger('play');">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.