I prefer use java play several audio one by one using the below code, however, all the audio in floder 'res' play simultaneously.
package com.company;
import java.io.*;
import sun.audio.*;
public class Main {
public static void main(String[] args)
throws Exception
{
String resPath="res/";
File f=new File(resPath);
File[] result=f.listFiles();
String[] filePath=new String[result.length];
for(int i=0;i<result.length;i++){
filePath[i]=resPath+result[i].getName();
}
for(String audioPath:filePath) {
InputStream in = new FileInputStream(audioPath);
AudioStream audioStream = new AudioStream(in);
AudioPlayer.player.start(audioStream);
}
}
}
Please help me. Thanx.