I am using an external library for my android project. With that library i am getting the ID3 tags from stream Mp3 url. The code uses URLConnection to reach the link and then gets the tag informations.But the problem is its a very slow procedure.
while doing it on a main thread it takes more than 2 minutes to get ID3 tags of 25 songs from their URLs. So i decided to use multiple AsyncTasks to make the process faster and i used this code below. It became faster a bit, but still few seconds below 2 minute mark. When i checked the Threads tab from DDMS and i saw that during the runtime, there is only 6 AsyncTask is created and running.
My question is , how can i increase the number of AsyncTask running , in this loop.
counter=0;
for (final SongDetail e : songs) {
new AsyncTask<Void , Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
MP3 mp3 = new MP3(e.getLink());
e.setTitle(mp3.getTitle());
e.setArtist(mp3.getBand());
} catch (MalformedURLException e1) {
e1.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
counter++;
if(counter==songs.size()) {
Log.d("KA","loop finished");
}
}
}.execute();
}