I am using MediaController.MediaPlayerControl to display the MediaController at the bottom of my custom view, but I cannot get it to work correctly. When I play music for the first time, then there should be a pause button, but there is playback instead, and when I press this button, the music pauses correctly and the state remains unchanged and after that it works correctly. Also, when I play the next song, the old MediaController widget overlaps the new one. And sometimes the progress / search indicator is not updated during music playback. It just updates when something is clicked on the MediaController (Play / Pause, forward, etc.).
I found these questions to be similar to mine, but I don’t think the answers they received solve my problem.
This is how I initialize the controller:
private void setController()
{
controller = new MusicController(this);
controller.setPrevNextListeners(new View.OnClickListener() {
@Override
public void onClick(View v) {
playNext();
}
}, new View.OnClickListener() {
@Override
public void onClick(View v) {
playPrev();
}
});
controller.setMediaPlayer(this);
controller.setAnchorView(findViewById(R.id.song_list));
controller.setEnabled(true);
}
This is how I show the controller:
public void playMusic()
{
musicSrv.playSong();
setController();
controller.show(0);
controller.requestFocus();
}
source
share