Lets say I have several players I’ve created.
And Lets say that for each one of them, I want a different set on actions to be activated.
How can I locate which player has been finished (the implementation itself of the case sentence) in order to act differently for each player ?
For example: in order to handle a single player, all we have to do is to implement the onCompletion() method like this:
public void onCompletion(MediaPlayer mp){
//DO SOMETHING HERE THAT FITS FOR ALL KINDS OF PLAYER'S TYPE OBJECTS
}
How do I add a case sentence to expand it to handle several different player objects ?
Thanks !
The
MediaPlayerattribute passed to this method is the sameMediaPlayerthat has just completed, so as long as you are keeping a pointer to each media player (such as through a global variable), then all you need to do is check which media player you have received:You can also handle this in-line, without implementing the
OnCompleteListener: