MediaRecorder start failed: -38

匿名 (未验证) 提交于 2019-12-03 02:49:01

问题:

i searched to check if this question is no dup , i see some has no answer and others did not help.

this is my code :

private void startRecording() {             mRecorder = new MediaRecorder();             mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);             mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);             mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);              mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();               mFileName += "/recordedHeckPost_.3gp";              mRecorder.setOutputFile(mFileName);                                    try {                     mRecorder.prepare();                     //Thread.sleep(2000);                     mRecorder.start();                           }                 catch (InterruptedException e)                  {   // TODO Auto-generated catch block             e.printStackTrace();         }                  catch(IllegalStateException e)             {                 e.printStackTrace();             } catch (IOException e) {             // TODO Auto-generated catch block             e.printStackTrace();         } }  private void stopRecording() {         mRecorder.stop();         mRecorder.release();         mRecorder = null; } 

After running this code (On Nexus 5) i get the below start failed -38 exception:

05-31 18:17:39.404: E/MediaRecorder(2464): start failed: -38 05-31 18:17:39.404: W/System.err(2464): java.lang.IllegalStateException 05-31 18:17:39.404: W/System.err(2464):     at android.media.MediaRecorder.start(Native Method) 

Thanks.

回答1:

Found the solution , it appears i had some other service in the background which is using AudioRecord and uses the mic as well.... so thats the -38 :)



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!