Cordova Media Play sequencial Audios with delay

Multi tool use
Cordova Media Play sequencial Audios with delay
Im trying to play 3 audio files sequencially, with 1 second delay.
This code works well at Android Device(actual device, after build), but on iOs(via xcode run) and browser it wait 3 seconds(3000 milisecondes) and play all at once.
What could be the solution for all platforms?
function playAudio(files) {
var arquivos = files.split('-')
for (var i = 0, length = arquivos.length; i < length; i++)
{
var arquivo = 'media/notas/'+arquivos[i]+'.mp3'
my_media = new Media(getMediaURL(arquivo),function () {},function (err) { window.alert("playAudio():Audio Error: " + err)});
my_media.play();
console.log(getMediaURL(arquivo))
wait(1000);
}
function wait(ms){
var start = new Date().getTime();
var end = start;
while(end < start + ms) {
end = new Date().getTime();
}
}
while(end < start + ms) {
await
Thanks for the tip, but I'm getting the same result: iOs and Browser waits 3seconds and play all at once.
– alexandrecfb
Jul 2 at 13:52
It sounds like you're not using
await
properly..? Await a Promise
that resolves after a second– CertainPerformance
Jul 2 at 22:25
await
Promise
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
while(end < start + ms) {
That's a lot of CPU usage, couldn't you useawait
instead?– CertainPerformance
Jul 1 at 20:51