Android 2.3“启动失败-2147483648”mediaRecorder错误

时间:2012-08-12 21:01:52

标签: android api video mediarecorder

在Android 2.2上,代码在2.3上工作正常但它在MediaRecorder.start()崩溃了。日志和代码本身如下。如您所见,它没有提供太多信息,日志会显示“start failed -2​​147483648”消息。我已经尝试了很长时间,无法弄明白这一点,我做错了什么?

    mediaRecorder = new MediaRecorder();

    try {
        camera.unlock();

        mediaRecorder.setCamera(camera);

        mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

        mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
    mediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());

        mediaRecorder.setPreviewDisplay(cameraPreview.getHolder().getSurface());

        mediaRecorder.prepare();

        mediaRecorder.start(); // thats the line code fails

        fightTimer.start();
    } 
    catch (RuntimeException ex) {
        Toast.makeText(this,"Sorry, camera is currently not available"+ex.toString(), 2000).show();
    } 
    catch (IOException ex) {
        Toast.makeText(this,"Sorry, camera is currently not available"+ex.toString(), 2000).show();
    }

并记录

08-13 06:34:56.914: I/MediaRecorderJNI(2256): prepare: surface=0x2bb230 (identity=13)
08-13 06:34:57.764: E/MediaRecorder(2256): start failed: -2147483648

1 个答案:

答案 0 :(得分:0)

这只是一个错误的错误代码。但是,第一行prepare: surface表示与构建VideoPlayer边界相关的内容,突然发生异常。

你需要setVideoSize()吗?

提示:我会搜索“android mediarecorder start failed”(没有错误代码 - 似乎这些错误代码与错误消息本身一样随机!)

修改 由于它适用于Android 2.2,您是否看过API 2.2和API 2.3之间针对MediaRecorder的API更改?