Skip to content

Instantly share code, notes, and snippets.

@chrissound
Created September 13, 2014 19:07
Show Gist options
  • Select an option

  • Save chrissound/b357e3cafff8b27b77b2 to your computer and use it in GitHub Desktop.

Select an option

Save chrissound/b357e3cafff8b27b77b2 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