I have a code which is checking a defined type of audio file in folder and calling converter to change its format. Now when first file is passed, converter is called and as file is in process of being conversion, for loop called converter again for second file. In this i felt earlier/later process is terminated and hence i m getting only file converted as output. Code is here. How can i manage to get all files convereted.
public void convertAudio(View v) {
final File pathanme = new File(Environment.getExternalStorageDirectory() + "/sdcard/test");
File files[] = pathanme.listFiles();
for (File f : files) {
if (f.getName().endsWith(".mp4")) {
String filename = f.getName().toLowerCase().toString();
System.out.println(filename);
File wavFile = new File(pathanme, filename);
IConvertCallback callback = new IConvertCallback() {
@Override
public void onSuccess(File convertedFile) {
Toast.makeText(NewMainActivity.this, "SUCCESS: " + convertedFile.getPath(), Toast.LENGTH_LONG).show();
}
@Override
public void onFailure(Exception error) {
Toast.makeText(NewMainActivity.this, "ERROR: " + error.getMessage(), Toast.LENGTH_LONG).show();
}
};
Toast.makeText(this, "Converting audio file..." + filename, Toast.LENGTH_SHORT).show();
AndroidAudioConverter.with(this)
.setFile(wavFile)
.setFormat(AudioFormat.MP3)
.setCallback(callback)
.convert();
}
}
If u see there is success message against conversion and i never got this under for loop whereas if i pass only one file, i got success message. pls advice.