Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8765657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:20:25+00:00 2026-06-13T16:20:25+00:00

Lets say I have several players I’ve created. And Lets say that for each

  • 0

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 !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:20:29+00:00Added an answer on June 13, 2026 at 4:20 pm

    The MediaPlayer attribute passed to this method is the same MediaPlayer that 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:

    public class MyClass implements OnClompleteListener 
    {
        MediaPlayer player1, player2, player3;
        //initialize them
        player1.setOnCompleteListener(this);
        player2.setOnCompleteListener(this);
        player3.setOnCompleteListener(this);
    
        @Override
        public void onCompletion(MediaPlayer mp)
        {
            if (mp == player1)
            {
                //TODO handle player 1 completion
            }
            else if (mp == player2)
            {
                //TODO handle player 2 completion
            }
            else if (mp == player3)
            {
                //TODO handle player 3 completion
            }
        }
    }
    

    You can also handle this in-line, without implementing the OnCompleteListener:

    player1.setOnCompleteListener(new OnCompleteListener() {
    
        @Override
        public void onCompletion(MediaPlayer mp)
        {
            //mp IS ALWAYS EQUAL TO player1!
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say that I have several DevExpress controls and one of them is a
lets say I have a string that I want to split based on several
I have an app that contains several activities...so lets say user is navigating activity
lets say I have an NSWindow Class, that has several events for mouse and
I have one field that I need to sum lets say named items However
Lets say I have a table containing several hundred million rows that looks something
I have a function that updates several tables. As an example, let's say it
Lets say I have several sets of options in Javascript var color = [red,
Lets say you make a game engine, and you have several GameObjects and every
If I have a several header files :lets say 1.h , 2.h , 3.h

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.