i have an array of audio files that i want to play them one by one, unfortunately when i tap play, both play at the same time meaning for loop iterate through both and plays. i tried to add setTimeout to 5 sec. then go to the next audio but nothing worked still i can hear both of them.
all i want to act like normal player playing one audio file at a time and once audio file is finished playing, the for loop goes to the next audio in my array till all are played.
this.songs.loadPlaylistSongs(pid).then((p)=>{
if(p.length > 0){
for(let z=0; z<p.length; z++){
let music = p[z].song;
//now play music..
this.file = new MediaPlugin(music);
this.file.play({ playAudioWhenScreenIsLocked : true });
setTimeout(() => {
this.file.stop();
}, 5000);
}
}
}else{ this.tt("Sorry, Playlist has no songs.."); }
}).catch((err)=>{ this.tt(JSON.stringify(err)); });