Search code examples
androidmedia-player

How to know my media file playing has been stopped in android


I have a buttons called play and stop if I press play its starting playing. after I press stop its going to home page. But I need to go home page automatically once playing is done ie. Without clicking stop button. How can I do it for android? thanks in advance


Solution

  • hi shekhar you can set an oncomplete listener to the player object. The code follows:

    mPlayer.setOnCompletionListener(new OnCompletionListener(){@Override public void onCompletion(MediaPlayer mp) {  "your code comes here" }});
    

    here the mPlayer is the object of the MediaPlayer which is currently running..