播放器暂停但未恢复
我的代码
btnplay.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mediaPlayer.isPlaying()) {
Currentposition = mediaPlayer.getCurrentPosition();
mediaPlayer.pause();
mediaPlayer.seekTo(currentPosition);
btnplay.setImageResource(R.drawable.img_btn_play);
else {
mediaPlayer.start();
btnplay.setImageResource(R.drawable.img_btn_pause);
try {
mediaPlayer.setDataSource(songs_url[counter]);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.prepare();
mediaPlayer.start();
btnplay.setImageResource(R.drawable.img_btn_pause);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});