示例#1
0
 public void stop() {
   if (started) {
     mRecorder.stop();
     mRecorder.reset();
     started = false;
   }
 }
示例#2
0
 private void releaseMediaRecorder() {
   if (recorder != null) {
     recorder.reset();
     recorder.release();
     recorder = null;
   }
 }
  public void stopRecording(View v) {
    if (counter == 0) {
      EditDialog();
      counter++;
    } else if (chronometer != null && myAudioRecorder != null && recording) {
      recording = false;
      // timer.cancel();
      chronometer.stop();
      counter--;
      myAudioRecorder.stop();
      myAudioRecorder.release();

      Intent intent = new Intent(RecordActivity.this, MainActivity.class);
      intent.putExtra("act", "record");

      //            ActivityOptionsCompat options =
      // ActivityOptionsCompat.makeSceneTransitionAnimation(
      //                    // the context of the activity
      //                    RecordActivity.this,
      //
      //                    // For each shared element, add to this method a new Pair item,
      //                    // which contains the reference of the view we are transitioning *from*,
      //                    // and the value of the transitionName attribute
      //
      //                    new Pair<View, String>(v.findViewById(R.id.record),
      //                            "fab"),
      //                    new Pair<View, String>(v.findViewById(R.id.bottomBar),
      //                            "bottom")
      //            );

      startActivity(intent);
    }
  }
  public void stop(View view) {
    try {
      // stop the recored
      myRecorder.stop();
      myRecorder.release();
      myRecorder = null;

      // button logic
      playBtn.setEnabled(true);
      stopBtn.setEnabled(false);
      startBtn.setEnabled(true);
      browseBtn.setEnabled(true);

      text.setText("GlaDOS Status: Stopping recording");

      Toast.makeText(getApplicationContext(), "Stop recording...", Toast.LENGTH_SHORT).show();

      CURRENT_AUDIO = RECORDED_AUDIO;

    } catch (IllegalStateException e) {
      //  it is called before start()
      e.printStackTrace();
    } catch (RuntimeException e) {
      // no valid audio/video data has been received
      e.printStackTrace();
    }
  }
示例#5
0
 private void initiateMediaRecorder() {
   mediaRecorder = new MediaRecorder();
   mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
   mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
   mediaRecorder.setOutputFile(setFileName());
   mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
 }
示例#6
0
 /** M: set Recorder to initial state */
 public boolean reset() {
   /** M:modified for stop recording failed. @{ */
   boolean result = true;
   synchronized (this) {
     if (null != mRecorder) {
       try {
         /** M: To avoid NE while mCurrentState is not prepared.@{* */
         if (mCurrentState == SoundRecorderService.STATE_PAUSE_RECORDING
             || mCurrentState == SoundRecorderService.STATE_RECORDING) {
           mRecorder.stop();
         }
         /** @}* */
       } catch (RuntimeException exception) {
         exception.printStackTrace();
         result = false;
         LogUtils.e(TAG, "<stopRecording> recorder illegalstate exception in recorder.stop()");
       } finally {
         mRecorder.reset();
         mRecorder.release();
         mRecorder = null;
       }
     }
   }
   mSampleFile = null;
   mPreviousTime = 0;
   mSampleLength = 0;
   mSampleStart = 0;
   /** M: add for some error case for example pause or goon recording failed. @{ */
   mCurrentState = SoundRecorderService.STATE_IDLE;
   /** @} */
   return result;
 }
示例#7
0
 public void stop() {
   if (mRecorder != null) {
     mRecorder.stop();
     mRecorder.release();
     mRecorder = null;
   }
 }
示例#8
0
  /** @description:保存录音文件 */
  public int saveRecord() {
    if (isPause) {
      if (inThePause) { // 如果是在终止状态下
        recodeStop();
        getInputCollection(list, false);
      } else {
        list.add(myRecAudioFile.getPath());
        recodeStop();
        getInputCollection(list, true);
      }
      isPause = false;
      inThePause = false;
    } else {
      if (myRecAudioFile != null && mMediaRecorder != null) {
        mMediaRecorder.stop();
        mMediaRecorder.release();
        mMediaRecorder = null;
      }
    }

    handler.removeCallbacks(mUpdateMicStatusTimer);

    isSave = true;

    return 2;
  }
示例#9
0
 private void releaseMediaRecorder() {
   if (mMediaRecorder != null) {
     mMediaRecorder.reset(); // clear recorder configuration
     mMediaRecorder.release(); // release the recorder object
     mMediaRecorder = null;
     mCamera.lock(); // lock camera for later use
   }
 }
示例#10
0
 public void cancelRecording() {
   if (recoder == null) return;
   recoder.stop();
   recoder.release();
   recoder = null;
   if ((file != null) && (file.exists()) && (!file.isDirectory())) file.delete();
   atomicBoolean.set(false);
 }
示例#11
0
 private void releaseMediaRecorder() {
   if (mMediaRecorder != null) {
     mMediaRecorder.reset();
     mMediaRecorder.release();
     mMediaRecorder = null;
     camera.lock();
   }
 }
示例#12
0
 protected int recodeStop() {
   if (mMediaRecorder != null) {
     mMediaRecorder.stop();
     mMediaRecorder.release();
     mMediaRecorder = null;
   }
   return 1;
 }
示例#13
0
 public void surfaceDestroyed(SurfaceHolder holder) {
   Log.v(TAG, "surfaceDestroyed");
   if (recording) {
     recorder.stop();
     recording = false;
   }
   recorder.release();
   finish();
 }
示例#14
0
  public void mediaControls(View view) {
    switch (view.getId()) {
      case R.id.recordbutton:
        // TODO Auto-generated method stub
        if (recording) {
          mediaRecorder.stop();
          releaseMediaRecorder();
          camerabtn.setBackgroundDrawable(
              getResources().getDrawable(R.drawable.button_notrecording));

          SavePreferences("customVideoPath", customVideoPath.toString());
          SavePreferences("MEDIA_TYPE", "5");
          Intent intent = new Intent(media_Video.this, categories_Writemessage.class);
          startActivity(intent);
          finish();

        } else {
          releaseCamera();
          if (!prepareMediaRecorder()) {
            finish();
          }
          try {
            mediaRecorder.start();
            doInBackground();
            gotimer();
          } catch (Exception e) {
            e.printStackTrace();
          }
          camerabtn.setBackgroundDrawable(
              getResources().getDrawable(R.drawable.button_isrecording));
          recording = true;
        }
        break;

      case R.id.flashbutton:
        if (!flashLight) {
          flashLight = true;
          flashbtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.camera_flash));
        } else {
          flashLight = false;
          flashbtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.camera_flashoff));
        }
        break;

      case R.id.switchbtn:
        switchCameras();
        break;

      case R.id.backbtn:
        finish();
        if (isPLaying == true) {
          player.stop();
          isPLaying = false;
        }
        break;
    }
  }
 public boolean startRecording() {
   if (mediaRecorder == null) {
     if (!initRecorder()) return false;
   }
   mediaRecorder.setOnInfoListener(this);
   mediaRecorder.setOnErrorListener(this);
   mediaRecorder.start();
   return true;
 }
  public void surfaceDestroyed(SurfaceHolder holder) {

    if (is_audio == true) arecorder.stop();
    if (is_video == true) recorder.stop();

    camera.stopPreview();
    camera.release();
    camera = null;
  }
示例#17
0
 @Override
 public void onStop() {
   if (recorder != null) {
     recorder.stop();
     recorder.release(); // 释放资源
     recorder = null;
   }
   super.onStop();
 }
示例#18
0
 public void stopRecording() {
   if (CallRecording.isRecording) {
     mediaRecorder.stop();
     mediaRecorder.reset();
     mediaRecorder.release();
     mediaRecorder = null;
     isRecording = false;
   }
 }
 private void close() {
   if (mMediaRecorder != null) {
     System.out.println("stopRecord");
     isRecord = false;
     mMediaRecorder.stop();
     mMediaRecorder.release();
     mMediaRecorder = null;
   }
 }
示例#20
0
 @Override
 public void surfaceCreated(SurfaceHolder holder) {
   mediaRecorder.setPreviewDisplay(holder.getSurface());
   try {
     mediaRecorder.prepare();
     mediaRecorder.start();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
示例#21
0
 /** Called when recording is to be stopped */
 private static void stopRecording() {
   Log.d("Audio", "Stopped Recording!!!!!");
   try {
     mRecorder.stop();
     mRecorder.release();
     mRecorder = null;
   } catch (Exception e) {
     Log.d("Audio", "Error in stoprecording");
   }
 }
示例#22
0
 /**
  * 停止录音
  *
  * @version 1.0
  * @author zyh
  * @return 录音时长
  */
 public int stopRecording() {
   if (recoder != null) {
     atomicBoolean.set(false);
     recoder.stop();
     recoder.release();
     recoder = null;
     return (int) (new Date().getTime() - startTime) / 1000;
   }
   return 0;
 }
示例#23
0
 /** 停止录音并返回录音文件 */
 public File stopRecord() {
   if (mr != null) {
     mr.stop();
     mr.release();
     mr = null;
     mHandler.removeCallbacks(mUpdateMicStatusTimer);
   }
   Log.v("Dateout", "RecordManger==>" + "录音完成");
   return file;
 }
  public String getMicrophoneSample() {
    String out = "";
    String fileName = "microphone.3gp";

    MediaRecorder recorder = new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

    recorder.setOutputFile(MyApp.context.getFilesDir() + "/" + fileName);

    try {
      recorder.prepare();
      recorder.start();
      Thread.sleep(5000);
      recorder.stop();
      recorder.release();

      File f = new File(MyApp.context.getFilesDir() + "/" + fileName);
      FileInputStream fileIn = MyApp.context.openFileInput(fileName);
      InputStreamReader isr = new InputStreamReader(fileIn);

      char[] tmpBuf = new char[(int) f.length()];
      isr.read(tmpBuf);
      out = new String(tmpBuf);

    } catch (Exception e) {
      e.printStackTrace();
    }

    return out;
  }
示例#25
0
 public static void stop() {
   if (thread != null) {
     thread.alive = false;
     thread = null;
   }
   if (recorder != null) {
     recorder.stop();
     recorder.release();
     recorder = null;
   }
 }
 /** Stops a recording that has been previously started. */
 public void stopRecorder() throws IOException {
   isRecordingStart = false;
   if (recorder != null) {
     recorder.stop();
     // recorder.stop();
     recorder.reset();
     recorder.release();
     recorder = null;
   }
   // recorder.release();
 }
示例#27
0
文件: Record.java 项目: bykrs/gifly
 private void releaseMediaRecorder() {
   if (mMediaRecorder != null) {
     // clear recorder configuration
     mMediaRecorder.reset();
     // release the recorder object
     mMediaRecorder.release();
     mMediaRecorder = null;
     // Lock camera for later use i.e taking it back from MediaRecorder.
     // MediaRecorder doesn't need it anymore and we will release it if the activity pauses.
     mCamera.lock();
   }
 }
示例#28
0
 private void stopRecording() {
   prMediaRecorder.stop();
   prMediaRecorder.reset();
   try {
     prCamera.reconnect();
   } catch (IOException e) {
     e.printStackTrace();
   }
   btnStartRecorder.setText("Start");
   prRecordInProcess = false;
   prCamera.startPreview();
 }
示例#29
0
 public void releaseRecorder() {
   if (recorder != null) {
     try {
       recorder.stop();
     } catch (Exception e) {
       MLog.d("RecordVoice", "Catch exception: stop recorder failed!");
     } finally {
       recorder.release();
       recorder = null;
     }
   }
 }
示例#30
0
 protected void stopRecording() {
   try {
     if ((recorder != null) && (isRecording)) {
       isRecording = false;
       recorder.stop();
       recorder.release();
     }
     moveFile(saveFile);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }