android - MediaRecorder start failed -19 and Camera error 100 -


i developing app record video.

i got code in app running fine in nexus 4 , sony ericsson mini pro, when test in other devices, archos 80g9 , jiayu g3st, app gives me following error

"mediarecorder start failed -19"

or

"camera error 100 ".

i tried implementing changes suggested in other stackoverflow posts error still appears.

private boolean preparevideorecorder() {     /** added sony ericsson stoped */     try {         mcamera.setpreviewdisplay(null);     } catch (java.io.ioexception ioe) {         log.d(tag,                     "ioexception nullifying preview display: "                             + ioe.getmessage());     }     mcamera.stoppreview();      mmediarecorder = new mediarecorder();     // step 1: unlock , set camera mediarecorder     mcamera.unlock();     mmediarecorder.setcamera(mcamera);      // step 2: set sources     mmediarecorder.setaudiosource(mediarecorder.audiosource.camcorder);     mmediarecorder.setvideosource(mediarecorder.videosource.camera);      // step 3: set camcorderprofile (requires api level 8 or higher)     camerabackfront cm = new camerabackfront();     int id = cm.getbackcameraid();     if (qualitystring().equalsignorecase("low")) {         mmediarecorder.setprofile(camcorderprofile.get(id,                     camcorderprofile.quality_low));     } else if (qualitystring().equalsignorecase("high")) {         mmediarecorder.setprofile(camcorderprofile.get(id,                     camcorderprofile.quality_high));     } else if (qualitystring().equalsignorecase("480p")) {         mmediarecorder.setprofile(camcorderprofile.get(id,                     camcorderprofile.quality_480p));     } else if (qualitystring().equalsignorecase("720p")) {         mmediarecorder.setprofile(camcorderprofile.get(id,                     camcorderprofile.quality_720p));     } else if (qualitystring().equalsignorecase("1080p")) {         try {             mmediarecorder.setprofile(camcorderprofile.get(id,                         camcorderprofile.quality_1080p));         } catch (exception e) {             mmediarecorder.setprofile(camcorderprofile.get(id,                         camcorderprofile.quality_high));         }     } else {         mmediarecorder.setprofile(camcorderprofile.get(0,                     camcorderprofile.quality_high));     }      // step 4: set output file     mmediarecorder.setoutputfile(getoutputmediafile(media_type_video)                 .tostring());     /** add file name */     addfilenamedb();     // step 5: set preview output     mmediarecorder.setpreviewdisplay(mpreview.getholder().getsurface());      // step 6: prepare configured mediarecorder     try {         mmediarecorder.prepare();     } catch (illegalstateexception e) {         log.d(tag,                     "illegalstateexception preparing mediarecorder: "                             + e.getmessage());         releasemediarecorder();         return false;     } catch (ioexception e) {         log.d(tag, "ioexception preparing mediarecorder: " + e.getmessage());         releasemediarecorder();         return false;     }      return true; } 

i have tried:

  • put thread.sleep(1000); before mediarecorder.start() gives me error.
  • put default camerapreview in development.android.com.
  • my app works custom camerapreview resized preview.
  • i obtain camera qualitys camcorderprofile.hasprofile(camcorderprofile.quality_720p) , because uses profiles work on phone.

finally fix problem using

... releasecamera(); if(preparevideorecorder){    ... } 

before preparevideorecorder().

and preparevideorecorder add new instance of camera.

public void preparevideorecorder(){    mcamera = getcamerainstance();    ... } 

with things have fixed:

  • mediarecorder start failed -19.
  • camera error 100 (media server died , camera died ).

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -