Пример #1
0
  private void stopRecording(boolean isComingFromViewClick) {
    if (countDownTimer != null) {
      countDownTimer.cancel();
    }

    // //// ****** Handles UI items on button click ****** ///////
    editStopButton.setVisibility(View.GONE);
    editPlayButton.setVisibility(View.VISIBLE);
    editRerecordButton.setVisibility(View.VISIBLE);

    // //// ******* Stop Recording Audio and stop chronometer ******** ////////
    if (mRecordingHelper != null && mRecordingHelper.isRecording()) {
      mRecordingHelper.stopRecording();
    }
    editTimeDetailsChronometer.stop();

    if (mAudioPlay != null && mAudioPlay.isAudioPlaying()) {
      mAudioPlay.stopPlayBack();
    }
    if (isFromFavorite) {
      mAudioPlay = new AudioPlay(mFavoriteList.id, this, isFromFavorite);
    } else {
      mAudioPlay = new AudioPlay(entry.id, this, isFromFavorite);
    }
    String displayTime =
        new DisplayTimeForChronometer().getDisplayTime(mAudioPlay.getPlayBackTime());
    editTimeDetailsChronometer.setText(displayTime);
    Map<String, String> map = new HashMap<String, String>();
    map.put("Display Time ", displayTime);
    FlurryAgent.onEvent(getString(R.string.audio_recording_time), map);
  }
Пример #2
0
 private void stopRecordingAndPlayback() {
   if (mRecordingHelper != null && mRecordingHelper.isRecording()) {
     if (editTimeDetailsChronometer != null) {
       editTimeDetailsChronometer.stop();
     }
     mRecordingHelper.stopRecording();
   }
   if (mAudioPlay != null && mAudioPlay.isAudioPlaying()) {
     if (editTimeDetailsChronometer != null) {
       editTimeDetailsChronometer.stop();
     }
     if (isFromFavorite) {
       mAudioPlay = new AudioPlay(mFavoriteList.id, this, isFromFavorite);
     } else {
       mAudioPlay = new AudioPlay(entry.id, this, isFromFavorite);
     }
     if (editTimeDetailsChronometer != null) {
       editTimeDetailsChronometer.setText(
           new DisplayTimeForChronometer().getDisplayTime(mAudioPlay.getPlayBackTime()));
     }
     mAudioPlay.stopPlayBack();
   }
 }
Пример #3
0
  @Override
  public void onClick(View v) {
    super.onClick(v);
    // ///// ******** Adding On Click Actions to click listeners ********* //////////

    switch (v.getId()) {

        // // ***** if stop button pressed ****** //////
      case R.id.edit_stop_button:
        stopRecording(true);
        break;
        // // ***** if play button pressed ****** //////
      case R.id.edit_play_button:
        // //// ******** to handle playback of recorded file ********* ////////
        if (isFromFavorite) {
          mAudioPlay = new AudioPlay(mFavoriteList.id, this, isFromFavorite);
        } else {
          mAudioPlay = new AudioPlay(entry.id, this, isFromFavorite);
        }

        // ///// ******* Chronometer Starts Countdown ****** ///////
        countDownTimer =
            new MyCountDownTimer(
                mAudioPlay.getPlayBackTime(),
                1000,
                editTimeDetailsChronometer,
                editStopButton,
                editPlayButton,
                mAudioPlay);

        // //// ****** Handles UI items on button click ****** ///////
        editPlayButton.setVisibility(View.GONE);
        editStopButton.setVisibility(View.VISIBLE);
        editRerecordButton.setVisibility(View.VISIBLE);

        // /// ******** Start Audio Playback and counter to play audio
        // ****** ///////
        if (!mAudioPlay.isAudioPlaying()) {
          mAudioPlay.startPlayBack();
        } else {
          mAudioPlay.stopPlayBack();
          mAudioPlay.startPlayBack();
        }
        countDownTimer.start();
        break;

        // // ***** if rerecord button pressed ****** //////
      case R.id.edit_rerecord_button:
        isChanged = true;
        if (countDownTimer != null) {
          countDownTimer.cancel();
        }

        // /// ******* If Audio PlayBack is there stop playing audio *******//////
        if (mAudioPlay != null && mAudioPlay.isAudioPlaying()) {
          mAudioPlay.stopPlayBack();
        }

        // //// ****** Handles UI items on button click ****** ///////
        editPlayButton.setVisibility(View.GONE);
        editStopButton.setVisibility(View.VISIBLE);
        editRerecordButton.setVisibility(View.GONE);

        // //// ****** Restarts chronometer and recording ******* ////////
        if (mRecordingHelper != null && mRecordingHelper.isRecording()) {
          mRecordingHelper.stopRecording();
        }
        File mPath;
        mDatabaseAdapter.open();
        if (isFromFavorite) {
          mPath = fileHelper.getAudioFileFavorite(mFavoriteList.id);
          mDatabaseAdapter.updateFileUploadedFavoriteTable(mFavoriteList.id);
        } else {
          mPath = fileHelper.getAudioFileEntry(entry.id);
          mDatabaseAdapter.updateFileUploadedEntryTable(entry.id);
        }
        mDatabaseAdapter.close();
        mRecordingHelper = new RecordingHelper(mPath, this);
        mRecordingHelper.startRecording();
        editTimeDetailsChronometer.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36);
        editTimeDetailsChronometer.setBase(SystemClock.elapsedRealtime());
        editTimeDetailsChronometer.start();
        break;

      default:
        break;
    }
  }