Android SoundPool: get notified when end of played

It can't be done with SoundPool as far as I can tell.

The only audio 'player' that I know which can provide a completion notification is MediaPlayer - it's more of a complex beast than SoundPool but allows setting an OnCompletionListener to be notified when playback is complete.


This is what I do:

On startup I get the length of each sound-click using a MediaPlayer:

private long getSoundDuration(int rawId){
   MediaPlayer player = MediaPlayer.create(context, rawId);
   int duration = player.getDuration();
   return duration;
}

and store the sound plus the duration together (in a DTO-type object).