0

다음 코드는 비디오 녹화를 허용하지 않습니다. 이 코드는 버튼을 통해 호출되지만 버튼은 고정됩니다. 캠코더 프로파일을 사용하여 비디오를 녹화하려고합니다.안드로이드 비디오 레코딩 응용 프로그램에 대한 캠코더 프로파일을 설정할 수 없습니다.

public void startRecording() { 

    mCamera.unlock(); 
    mrec.setCamera(mCamera); 
    CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); 
    mrec.setProfile(cpHigh);   

    File dir = new File(SdCardPath + Directory); 
    if (!dir.exists()) { 
     if (dir.mkdir()) { 
      Log.v(STORAGE_SERVICE, "Created directory"); 
     } else { 
      Log.v(STORAGE_SERVICE, "Failed to create Directory"); 
     } 
    } 

    FullFilePath = SdCardPath + Directory + RecordFileName; 

    mrec.setOutputFile(FullFilePath); 
    mrec.setPreviewDisplay(surfaceHolder.getSurface()); 
    try { 
     mrec.prepare(); 
    } catch (IllegalStateException e) { 
     e.printStackTrace(); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
    mrec.start(); 
} 
+0

나는 단지 그것을 다른 프로세스에서 잠긴 카메라를 사용하려는 시도의 발견 로그 캣 보았다 -> 'java.lang의. RuntimeException : 잠금을 해제하지 못했습니다' –

답변

1

항상 던져 예외를 잡기 위해 당신이 최선을 다 :

public void startRecording() { 

    try { 
     mCamera.unlock(); 
    catch (RuntimeException ex){ 
     // looks like camera was locked in the first place, who is using it? 
    } 
    mrec.setCamera(mCamera); 

      ///...the rest of your code. 
} 
관련 문제