我在網上搜索過,我找不到1001錯誤。幾秒鐘後,我得到相機100錯誤,但我無法找出第一個錯誤是什麼。有沒有人有任何想法?安卓相機錯誤1001 - 那是什麼?
8
A
回答
5
我在S3上遇到了這個錯誤。我相信我已將其追蹤到MediaRecorder如何使用相機預覽表面。在我的情況下,當我試圖開始錄製時,預覽顯示重置。我解決它通過清理我的代碼,只是使用的電話設置,啓動和停止在下面的SurfaceView實現(從Android Camera developer guide)預覽顯示:
public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
private SurfaceHolder mHolder;
private Camera mCamera;
public CameraPreview(Context context, Camera camera) {
super(context);
mCamera = camera;
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, now tell the camera where to draw the preview.
try {
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
} catch (IOException e) {
Log.d(TAG, "Error setting camera preview: " + e.getMessage());
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
// empty. Take care of releasing the Camera preview in your activity.
}
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// If your preview can change or rotate, take care of those events here.
// Make sure to stop the preview before resizing or reformatting it.
if (mHolder.getSurface() == null){
// preview surface does not exist
return;
}
// stop preview before making changes
try {
mCamera.stopPreview();
} catch (Exception e){
// ignore: tried to stop a non-existent preview
}
// set preview size and make any resize, rotate or
// reformatting changes here
// start preview with new settings
try {
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
} catch (Exception e){
Log.d(TAG, "Error starting camera preview: " + e.getMessage());
}
}
}
3
只是想我要在這裏增加一個職位的未來參考。這個問題困擾了我很長一段時間。 事實證明,我的問題是由不正確的預覽大小引起的,雖然解析集是從getSupportedPictureSize方法獲得的。
因此,例如,你可以得到的尺寸如下:
//first entry in list is 1392x1392 for front facing camera on an S3
List<Camera.Size> supportedPictureSizes = params.getSupportedPictureSizes();
設置這個分辨率或忽略了產品總數設置圖片大小將導致可怕的錯誤1001
如果遇到這種任何其他設備,我會建議嘗試不同的圖片尺寸。
0
所以還有另一個原因,爲什麼我在我的Galaxy S3上使用它。我在使用TextureView顯示我的相機預覽,並在成功預覽後按主頁按鈕,然後再次輸入應用程序時出現此可怕錯誤。在onResume()函數中,我再次啓動了預覽,發現我沒有在onSurfaceTextureDestroyed()函數中釋放SurfaceTexture實例變量。
我加釋放行此功能,它現在看起來像這樣和完美的作品:
@Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
mSurfaceTexture = null; //This was the offending culprit.
releaseMediaPlayer();
releaseVideoRecorder();
releaseCamera();
return false;
}
0
在我的情況下,三星S3,視頻尺寸參數沒有設置,這導致1001錯誤。使用預覽大小在媒體記錄器上設置視頻大小解決了問題。但是,此更改可能會在其他設備上失敗,因爲參數可能會或可能不會在所有設備中可用/設置。下面的代碼解決了設備的最:
if(params.get("video-size") != null && params.get("video-size").isEmpty()) {
int videoWidth = params.getPreviewSize().width;
int videoHeight = params.getPreviewSize().height;
mediaRecorder.setVideoSize(videoWidth, videoHeight);
} else {
mediaRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
}
相關問題
- 1. 安卓相機程序錯誤-2147483648
- 2. 安卓相機保存文件錯誤
- 3. 安卓相機zoom
- 4. 安卓相機frezes
- 5. 安卓相機setPreviewSize
- 6. 安卓相機錯誤 - 錯誤排隊緩衝區到SurfaceTexture,-32
- 7. 安卓:錯誤
- 8. 安卓相機菜單
- 9. 安卓相機中斷
- 10. 安卓相機意圖
- 11. 安卓相機的空氣
- 12. 錯誤1001 LoaderExceptions
- 13. 用安卓相機拍照
- 14. 什麼是@ *安卓android的
- 15. 安卓相機AutoFocus on Demand
- 16. 安卓相機預覽錯誤的長寬比
- 17. 安卓相機預覽
- 18. 安卓相機2 api MediaRecorder停止()錯誤
- 19. 安卓相機應用程序收到錯誤100
- 20. 安卓相機ISO設置
- 21. 安卓相機翻轉
- 22. 安卓相機檢測
- 23. 安卓相機SurfaceView替代
- 24. 安卓相機控件
- 25. 安卓相機在後臺
- 26. 相機預覽 - 安卓
- 27. 測光相機 - 安卓
- 28. Json錯誤connectin安卓網頁主機
- 29. 安卓相機意圖
- 30. 安卓相機濾鏡
什麼都這是我回滾到我的代碼的早期版本固定的,但我仍想知道跆拳道是1001錯誤,所以我能避免它在未來。 –