3

1.What steps I will reproduce the problem?

I tried to detect the playpause button in android default media controller, I can able detect the seek bar changes (get the seeking video position) using

vv.setOnPreparedListener(new OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mp) {
        // TODO Auto-generated method stub
        mp.start();
        mp.setOnSeekCompleteListener(new OnSeekCompleteListener() {
            @Override
            public void onSeekComplete(MediaPlayer mp) {
                // TODO Auto-generated method stub
                long cuntPost=mp.getCurrentPosition();
            }
        });
    }
});    

2. I also tried to implement the Mediacontroller.MediaPlayerControll interface this is also not work, how can I listen the playpause button in media controller which listener I can use?

Ziem
  • 6,579
  • 8
  • 53
  • 86
Ramesh C
  • 83
  • 1
  • 10

2 Answers2

0
    mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
    {
        @Override
        public void onCompletion(MediaPlayer mp)
        {
            //play next // repeat // shuffle?
        }
    });

    Button lButton = new Button(getApplicationContext());
    lButton.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            //play or pause logic
            if(mMediaPlayer.isPlaying())
            {
                mMediaPlayer.pause();
            }
            else
            {
                mMediaPlayer.start();
            }
        }
    });
    //call to check current state
    mMediaPlayer.isPlaying();
Klawikowski
  • 605
  • 3
  • 11
0

If you want to handle the UI not by yourself, you can refer to MediaController api.

http://developer.android.com/reference/android/widget/MediaController.html

Which gives you a UI and a Control object to control the MediaPlayer.

http://developer.android.com/reference/android/widget/MediaController.MediaPlayerControl.html

Vishnu Prabhu
  • 449
  • 1
  • 5
  • 19