I have a MediaPlayer member variable posted in my parent class, and after I start it, it doesn't ever call onCompletion, or at least onCompletionListener doesn't ever catch it? My code looks something to this effect
mediaPlayer = Mediaplayer.create(this, currentSample);
mediaPlayer.start();
elsewhere in code is my onCompletionListener
mediaPlayer.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
if (repeatFlag == true) {
handler.removeCallbacks(sampleRunnable);
handler.postDelayed(sampleRunnable, delay);
}
}
});
I'm using the handler to call sampleRunnable because I want to loop it at a specified delay interval. However, onCompletion seems to never be called. I'm quite positive of this because I've set breakpoints in onCompletion which never suspends the program, and I've tried stepping through and it never seems to be called. Any ideas?
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(new OnCompletionListener()
{
@Override
public void onCompletion(MediaPlayer arg0)
{
Log.v("Tag", "Completed");
}
});
This snippet works fine. The only difference is the "@Override" and I'm not sure if the "@Override" has effect on the code.
On my experience, the listener is not triggered on some devices :/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With