• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android Mediaplayer class - onCompletion never called

I'm building an app that has a music player that streams music from a website. The music is playing fine, but I want to have the next song automatically played when one song is finished. I am importing

"android.media.MediaPlayer.OnCompletionListener"

, am declaring

"implements OnCompletionListener"

in the Activity definition, am calling

"mp.setOnCompletionListener(this);"

in the onCreate(), and have coded

"public void onCompletion(MediaPlayer arg0)"

But the onCompletion method is never being called. I set breakpoints inside the method to try and determine why my code wasn't producing the expected results, but the method is just never called when one song ends.

Does anyone know what the problem might be? Before I had the music streaming from the internet, I had it playing files from the R.raw folder, and the same problem existed.

I don't know how to debug this, because it's a method that should be called automatically and is just never being called.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones