MediaRecorder.stop() hanging with Android 4.0 (ICS)

后端 未结 9 1195
夕颜
夕颜 2021-02-04 01:08

When calling stop() within my Video Capture activity, on occasion, the software will hang and will not come back to life. Only triggering an ANR by hitting \"Back\

9条回答
  •  一向
    一向 (楼主)
    2021-02-04 01:55

    check out this-

                @Override
        protected void onPause() {
            // TODO Auto-generated method stub
            super.onPause();
            releaseMediaRecorder();
            releaseCamera();
        }
         private void releaseMediaRecorder(){
              if (recorder != null) {
                  recorder.reset();   // clear recorder configuration
                  recorder.release(); // release the recorder object
                  recorder = null;
                  camera.lock();           // lock camera for later use
              }
          }
    
          private void releaseCamera(){
              if (camera != null){
                  camera.release();        // release the camera for other applications
                  camera = null;
              }
          }
                 public void stopRecording() { // Toast.makeText(this,"Inside the stop                   recording",Toast.LENGTH_SHORT).show();
            //  camera.unlock();
            recorder.stop();
                    // recorder.reset();
            recorder.release();#release the recorder after stop important.
    
        }
    

提交回复
热议问题