I am using soundpool to play my recorded file. I just want to know that is there any way to know when soundpool finish playing. here is my working code below.
public void soundPool() {
final float playbackSpeed = 1.5f;
final SoundPool soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC,
100);
final int soundId = soundPool.load(audiofile.getAbsolutePath(), 1);
AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
final float volume = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool arg0, int arg1, int arg2) {
soundPool.play(soundId, volume, volume, 1, 0, playbackSpeed);
}
});
}
Yes you have to use mediaplayer for this..but using mediaplayer you can't do fast forwarding. my suggestion is you use sound pool for playing sound and before playing ,you can check time duration of sound using mediaplayer and when time wil finish you can manually stop soundpool. simple i have done this in a project.