本文整理汇总了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);
}
示例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();
}
}
示例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);
}
}
示例4: AndroidRecorder
import android.media.MediaRecorder; //导入方法依赖的package包/类
public AndroidRecorder() {
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setOnErrorListener(this);
mMediaRecorder.setOnInfoListener(this);
}