當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaRecorder.setOnErrorListener方法代碼示例

本文整理匯總了Java中android.media.MediaRecorder.setOnErrorListener方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaRecorder.setOnErrorListener方法的具體用法?Java MediaRecorder.setOnErrorListener怎麽用?Java MediaRecorder.setOnErrorListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.media.MediaRecorder的用法示例。


在下文中一共展示了MediaRecorder.setOnErrorListener方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: RecordingController

import android.media.MediaRecorder; //導入方法依賴的package包/類
RecordingController(String savedRecording) throws IOException {
  // pick a pathname if none was specified
  file = (savedRecording.equals("")) ?
      FileUtil.getRecordingFile("3gp").getAbsolutePath() :
        savedRecording;

  recorder = new MediaRecorder();
  recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
  recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
  Log.i(TAG, "Setting output file to " + file);
  recorder.setOutputFile(file);
  Log.i(TAG, "preparing");
  recorder.prepare();
  recorder.setOnErrorListener(SoundRecorder.this);
  recorder.setOnInfoListener(SoundRecorder.this);
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:18,代碼來源:SoundRecorder.java

示例2: initRecord

import android.media.MediaRecorder; //導入方法依賴的package包/類
private void initRecord() {
        try {
            mMediaRecorder = new MediaRecorder();
            mMediaRecorder.reset();
            mMediaRecorder.setCamera(mCamera);
            mMediaRecorder.setOnErrorListener(this);
            mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
            mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);//視頻源
            mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);//音頻源
            mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);//視頻輸出格式 也可設為3gp等其他格式
            mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);//音頻格式
            mMediaRecorder.setVideoSize(mWidthPixel, mHeightPixel);//設置分辨率
//        mMediaRecorder.setVideoFrameRate(25);// 設置每秒幀數 這個設置有可能會出問題,有的手機不支持這種幀率就會錄製失敗,這裏使用默認的幀率,當然視頻的大小肯定會受影響
            if (mPictureSize < 3000000) {//這裏設置可以調整清晰度
                mMediaRecorder.setVideoEncodingBitRate(3 * 1024 * 512);
            } else if (mPictureSize <= 5000000) {
                mMediaRecorder.setVideoEncodingBitRate(2 * 1024 * 512);
            } else {
                mMediaRecorder.setVideoEncodingBitRate(1 * 1024 * 512);
            }
            mMediaRecorder.setOrientationHint(90);//輸出旋轉90度,保持豎屏錄製
            mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);//視頻錄製格式
            //mMediaRecorder.setMaxDuration(Constant.MAXVEDIOTIME * 1000);
            mMediaRecorder.setOutputFile(mRecordFile.getAbsolutePath());
            mMediaRecorder.prepare();
        } catch (Exception e) {
            e.printStackTrace();
            releaseCamera();
        }
    }
 
開發者ID:mChenys,項目名稱:AndroidFFmpegCompress,代碼行數:31,代碼來源:RecordView.java

示例3: startRecording

import android.media.MediaRecorder; //導入方法依賴的package包/類
private void startRecording() {
    String statusMessage = "";
    String audioFileName = prepareOutputFile();
    try {
        mRecorder = new MediaRecorder();
        mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        mRecorder.setOutputFile(audioFileName);
        mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
        mRecorder.setAudioEncodingBitRate(96000);
        mRecorder.setAudioSamplingRate(mSamplingRate);
        mRecorder.setOnErrorListener(mOnErrorListener);
        mRecorder.prepare();
        mRecorder.start();
        mRecordingStatus = RECORDING_STATUS_STARTED;
        startForeground(1, mRecordingNotif);
    } catch (Exception e) {
        e.printStackTrace();
        mRecordingStatus = RECORDING_STATUS_ERROR;
        statusMessage = e.getMessage();
    } finally {
        Intent i = new Intent(ACTION_RECORDING_STATUS_CHANGED);
        i.putExtra(EXTRA_RECORDING_STATUS, mRecordingStatus);
        if (mRecordingStatus == RECORDING_STATUS_STARTED) {
            i.putExtra(EXTRA_AUDIO_FILENAME, audioFileName);
        }
        i.putExtra(EXTRA_STATUS_MESSAGE, statusMessage); 
        sendBroadcast(i);
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:31,代碼來源:RecordingService.java

示例4: AndroidRecorder

import android.media.MediaRecorder; //導入方法依賴的package包/類
public AndroidRecorder() {
    mMediaRecorder = new MediaRecorder();
    mMediaRecorder.setOnErrorListener(this);
    mMediaRecorder.setOnInfoListener(this);
}
 
開發者ID:LeonHover,項目名稱:MediaCodecRecorder,代碼行數:6,代碼來源:AndroidRecorder.java


注:本文中的android.media.MediaRecorder.setOnErrorListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。