玩家暂停但没有恢复

时间:2016-01-12 16:05:00

标签: android android-mediaplayer

播放器暂停但未恢复

我的代码

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

0 个答案:

没有答案