4
I am starting in javascript and I have in my hands a simple project but they are breaking my head.
The project consists of creating a multitrack player (such as recording studio software) where by clicking on play, the client can hear all the recorded instruments on the track in question.
Follow an example I’m talking about: Multitrack.com
Well, I have the following Markup:
<audio id="player" src="audio/1.mp3" controls="controls" preload="auto"></audio><br />
<audio id="player1" src="audio/2.mp3" controls="controls" preload="auto"></audio><br />
<audio id="player2" src="audio/3.mp3" controls="controls" preload="auto"></audio><br />
<button id="play">►</button>
And just below, the following javascript:
<script>
var play = document.getElementById('play');
play.addEventListener('click', function() {
player.play();
player1.play();
player2.play();
});
</script>
So far ok. When I open a browser via PC, the Audios load correctly simultaneously. However, when opening the project by android phone, the audios start late (latency) which makes them not synchronized.
What my mistake?
Is there any solution to this?
Or some way to make the audios sync...
Onosendai Thanks for the answer :). I’ve been testing this option but I can’t insert more than 1 audio. For every audio I use, I need to generate a new request?
– AD Henrique
@Adhenrique, You can enter as many as you like - the example selector is generating only one Object. In your case it might be worth specifying the URL for the resource to be loaded from an attribute in each item, and then processing all the elements.
– OnoSendai
Onosendai, I have tested every possible way with the Web Audio API and really, it is wonderful everything that this api can do. But unfortunately it is not compatible with Ieca (yet). Which makes my project somewhat limited. As you can see, the site I used as sample does not use web audio api and the latency of the Audios is ZERO! :(
– AD Henrique
@Adhenrique A pity this limitation. =/
– OnoSendai