Skip to content

Instantly share code, notes, and snippets.

Created September 13, 2014 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fd44c97e107cc68b0183 to your computer and use it in GitHub Desktop.
Save anonymous/fd44c97e107cc68b0183 to your computer and use it in GitHub Desktop.
public void waitTillLoaded() {
try {
Log.d("hmm", "abc");
soundLoadedSemaphore.acquire(counter.i);
Log.d("hmm", "xyz");
} catch (Exception e)
{
}
}
public void loadSound(AssetFileDescriptor assetFile, String soundIndex)
{
counter.i++;
soundIndexes.put(soundIndex, soundPool.load(assetFile, 1));
soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
soundLoadedSemaphore.release();
// if I 'load' a single file, and put the following line below it does not hang
// soundLoadedSemaphore.acquire();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment