There is a JS code and this is the only way it works on the phone, otherwise it does not !!!
On page 20 blocks with its audio file inside this block. looks like that!
And click on each element plays its own melody! Ie, we click on any element playing a sound, if you click on the second, then the previous one has stopped the sound, and the current one has a click on the melody!
<div class="test"> <p>БЛОК-1!</p> <audio src="1.mp3" type="audio/mpeg"></audio> </div> There can be 1000 such blocks !!!
Here is the JS code that handles the code!
var blocks = document.querySelectorAll('.test'); for(var i = 0; i < blocks.length; i++) { var block = blocks[i]; block.onclick = function() { //действие при клике var path = '/android_asset/www/audio/'; var audioName = this.querySelector('audio').getAttribute('src'); var fullPath = path+audioName; var local1 = new Media(fullPath); local1.play(); }//конец функции }//конец цикла } How to stop playing an audio file when clicking on another item? And yes, if you translate the variable into the global, it does not work !! (remove from the function).
there are click methods. play(); stop(); pause();
I suffer already which day. offered this code in one forum, on the browser it works perfectly, but does not work on the android application below 5.0, and 5.0 and above without any complaints !! LINK TO JSFiddle CODE