本文介绍了Android MediaRecorder-启动失败:2.3.3上为-2147483648的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MediaRecorder可以在其他版本的Android上运行,但不能在2.3.3上运行:

The MediaRecorder works on other versions of Android but not on 2.3.3:

try {

    MediaRecorder mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
    mRecorder.setOutputFile( path + "r_" + FileName );

    int version = android.os.Build.VERSION.SDK_INT;
    Log.d("MP3Downloader", "V: " + version );

    if( version >= 8 ) {
        mRecorder.setAudioEncodingBitRate(16);
        mRecorder.setAudioSamplingRate(44100);
        mRecorder.setAudioChannels(2);
    }

    mRecorder.prepare();
    mRecorder.start();
} catch (Exception e) {
    Log.e("MP3Downloader", "MediaRecorder Failed: " + e.getMessage() );
}

我收到错误启动失败:仅在版本2.3.3上为-2147483648.我没有发现这个问题可以在其他地方解决.

I get error Start Failed: -2147483648 on version 2.3.3 only. I have not found this problem addressed anywhere else.

我也尝试过:

try {

    MediaRecorder mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

    FileOutputStream fos = new FileOutputStream( "r_" + FileName);

    mRecorder.setOutputFile( fos.getFD() );



    int version = android.os.Build.VERSION.SDK_INT;
    Log.d("MP3Downloader", "V: " + version );

    if( version >= 8 ) {
        mRecorder.setAudioEncodingBitRate(16);
        mRecorder.setAudioSamplingRate(44100);
        mRecorder.setAudioChannels(1);
    }

    mRecorder.prepare();
    mRecorder.start();
} catch (Exception e) {
    Log.e("MP3Downloader", "MediaRecorder Failed: " + e.getMessage() );
}

但是,我得到了例外:(只读文件系统)"

But, I get exception: "(Read-only file system)"

我拥有权限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

推荐答案

使用3gpp更改输出格式.

change your output format with 3gpp.

这篇关于Android MediaRecorder-启动失败:2.3.3上为-2147483648的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 16:57