本文整理汇总了Java中android.media.MediaRecorder.setAudioChannels方法的典型用法代码示例。如果您正苦于以下问题:Java MediaRecorder.setAudioChannels方法的具体用法?Java MediaRecorder.setAudioChannels怎么用?Java MediaRecorder.setAudioChannels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.MediaRecorder
的用法示例。
在下文中一共展示了MediaRecorder.setAudioChannels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startRecording
import android.media.MediaRecorder; //导入方法依赖的package包/类
public void startRecording() {
setFileNameAndPath();
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setOutputFile(mFilePath);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mRecorder.setAudioChannels(1);
mRecorder.setAudioSamplingRate(44100);
mRecorder.setAudioEncodingBitRate(192000);
try {
mRecorder.prepare();
mRecorder.start();
mStartingTimeMillis = System.currentTimeMillis();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
}
示例2: startRecording
import android.media.MediaRecorder; //导入方法依赖的package包/类
public static void startRecording(Context context, MediaRecorder recorder, String word) {
recorder.reset();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setMaxDuration(10000);
recorder.setAudioSamplingRate(16000);
recorder.setAudioEncodingBitRate(16000*4*1);
recorder.setAudioSamplingRate(44100);
recorder.setAudioChannels(1);
recorder.setOutputFile(context.getFilesDir().getAbsolutePath() + "/" + word + ".aac");
try {
recorder.prepare();
} catch (IOException e) {
e.printStackTrace();
}
recorder.start();
}
示例3: prepareMediaRecorder
import android.media.MediaRecorder; //导入方法依赖的package包/类
private boolean prepareMediaRecorder() {
try {
// final Activity activity = getActivity();
//if (null == activity) return false;
//final BaseCaptureInterface captureInterface = (BaseCaptureInterface) activity;
// setCameraDisplayOrientation(mCamera.getParameters());
mMediaRecorder = new MediaRecorder();
camera.stopPreview();
camera.unlock();
mMediaRecorder.setCamera(camera);
// boolean canUseAudio = true;
//boolean audioEnabled = !mInterface.audioDisabled();
//if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
// canUseAudio = ContextCompat.checkSelfPermission(activity, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
// if (canUseAudio && audioEnabled) {
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
// } else if (audioEnabled) {
// Toast.makeText(getActivity(), R.string.mcam_no_audio_access, Toast.LENGTH_LONG).show();
// }
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
final CamcorderProfile profile = CamcorderProfile.get(currentCameraId, CamcorderProfile.QUALITY_HIGH);
mMediaRecorder.setOutputFormat(profile.fileFormat);
mMediaRecorder.setVideoFrameRate(profile.videoFrameRate);
mMediaRecorder.setVideoSize(previewSize.width, previewSize.height);
mMediaRecorder.setVideoEncodingBitRate(profile.videoBitRate);
mMediaRecorder.setVideoEncoder(profile.videoCodec);
mMediaRecorder.setAudioEncodingBitRate(profile.audioBitRate);
mMediaRecorder.setAudioChannels(profile.audioChannels);
mMediaRecorder.setAudioSamplingRate(profile.audioSampleRate);
mMediaRecorder.setAudioEncoder(profile.audioCodec);
Uri uri = Uri.fromFile(FileUtils.makeTempFile(
new File(Environment.getExternalStorageDirectory(),
"/Omoshiroi/videos").getAbsolutePath(),
"VID_", ".mp4"));
mMediaRecorder.setOutputFile(uri.getPath());
// if (captureInterface.maxAllowedFileSize() > 0) {
// mMediaRecorder.setMaxFileSize(captureInterface.maxAllowedFileSize());
// mMediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() {
// @Override
// public void onInfo(MediaRecorder mediaRecorder, int what, int extra) {
// if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) {
// Toast.makeText(getActivity(), R.string.mcam_file_size_limit_reached, Toast.LENGTH_SHORT).show();
// stopRecordingVideo(false);
// }
// }
// });
// }
mMediaRecorder.setOrientationHint(90);
// mMediaRecorder.setPreviewDisplay(mPreviewView.getHolder().getSurface());
mMediaRecorder.prepare();
return true;
} catch (Exception e) {
camera.lock();
e.printStackTrace();
return false;
}
}