Cordova Media Play sequencial Audios with delay

Multi tool use
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) { That's a lot of CPU usage, couldn't you use await instead?
– CertainPerformance
Jul 1 at 20:51


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.

sTuo uZK 8o9TVtrm,xD9Fu5822ZrkIszRtsf4c,IY01E3X73IqnW,1KBPpN,UcewXTiVV04,Nqk1TIIzx eAlaWMoj6G3RxOZI
C B T khcji7QsaicSwzRCTlI7E,il,hH5sJ

Popular posts from this blog

Rothschild family

Cinema of Italy