1.我将复制问题的哪些步骤?
我尝试在android默认媒体控制器中检测playpause按钮,我可以使用

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。我也试过实现media controller.mediaplayercontroll接口这也不行,我怎么能监听media controller中的playpause按钮呢?

最佳答案

    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();

10-08 06:54