问题
I am using listview adapter to displays list of tracks.Each list item has play and stop icons to play and stop track.The issue I am having is that track gets played only once when i first click on play button.After that if i stop it by clicking on stop button and the try to play any track it doesn't get played.Through toast message i found out that holder.img1.setOnClickListener() method does get called but onPrepared() method doesn't get called on clicking on play button for second time or after that..If i replace mMediaPlayer.pause();
by mMediaPlayer.release();
still i get same result..If i put mMediaPlayer=new MediaPlayer();
inside onClick() method of holder.img1.setOnClickListener
above issue does get resolved but then clicking on multiple play buttons will start playing multiple tracks at same time which i don't want..
回答1:
Trying to help you is going to be a nightmare due to your naming conventions and lack of commenting. I would recommend that you change your naming convention so that people looking at your code have some idea as to what each of the variables are doing. Also small comments on can be very helpful when in understanding what it is you are trying to do.
回答2:
@Override
public void onPrepared(MediaPlayer mp)
{
Toast.makeText(context,"prepatre",Toast.LENGTH_LONG).show();
mMediaPlayer.start();
}
来源:https://stackoverflow.com/questions/26947105/mediaplayer-setonpreparedlistener-doesnt-get-called-for-second-time