本文整理匯總了Java中android.media.MediaRecorder.setAudioSamplingRate方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaRecorder.setAudioSamplingRate方法的具體用法?Java MediaRecorder.setAudioSamplingRate怎麽用?Java MediaRecorder.setAudioSamplingRate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.MediaRecorder
的用法示例。
在下文中一共展示了MediaRecorder.setAudioSamplingRate方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: startRecording
import android.media.MediaRecorder; //導入方法依賴的package包/類
public void startRecording() {
if (this.paras.isTonghualuyin()) {
try {
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(4);
mediaRecorder.setAudioSamplingRate(16000);
mediaRecorder.setOutputFormat(3);
mediaRecorder.setAudioEncoder(1);
mediaRecorder.setOutputFile(this.file.getAbsolutePath());
mediaRecorder.prepare();
mediaRecorder.start();
this.isRecord = true;
} catch (Exception e) {
this.isRecord = false;
mediaRecorder.reset();
mediaRecorder.release();
mediaRecorder = null;
}
}
}
示例4: initMediaRecorder
import android.media.MediaRecorder; //導入方法依賴的package包/類
private void initMediaRecorder() {
try {
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mediaRecorder.setAudioSamplingRate(44100);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mediaRecorder.setAudioEncodingBitRate(96000);
Date currentTime = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
fileName = dateFormat.format(currentTime) + ".m4a";
File audioFile = new File(getCacheDir().getAbsolutePath() + "/" + fileName); // FIXED: 路徑待確定
Log.i("nib", audioFile.getAbsolutePath());
mediaRecorder.setOutputFile(audioFile.getAbsolutePath());
mediaRecorder.prepare();
mediaRecorder.start();
} catch (IOException e) {
e.printStackTrace();
}
}
示例5: startRecording
import android.media.MediaRecorder; //導入方法依賴的package包/類
private void startRecording() {
audioRec = new MediaRecorder();
audioRec.setAudioSource(MediaRecorder.AudioSource.MIC);
audioRec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
audioRec.setOutputFile(audioFilePath);
audioRec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
audioRec.setAudioSamplingRate(256);
try {
audioRec.prepare();
audioRec.start();
} catch (IOException e) {
e.printStackTrace();
}
}
示例6: prepare
import android.media.MediaRecorder; //導入方法依賴的package包/類
public void prepare() throws IOException {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mRecorder.setAudioSamplingRate(44100);
mRecorder.setAudioEncodingBitRate(96000);
mRecorder.setOutputFile(mFilePath);
mRecorder.prepare();
}
示例7: 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);
}
}
示例8: AudioRecordingAacThread
import android.media.MediaRecorder; //導入方法依賴的package包/類
public AudioRecordingAacThread() {
try{
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
// 設置MediaRecorder錄製的音頻格式(不要修改其它格式了,後端對格式做了限定)
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setAudioSamplingRate(8000);
}catch (Exception e){
}
}
示例9: onRecordClick
import android.media.MediaRecorder; //導入方法依賴的package包/類
public void onRecordClick(View v) {
if (!mRecording) {
File f = new File(getExternalFilesDir(null), "recording.mp4");
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setOutputFile(f.getAbsolutePath());
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC_ELD);
mRecorder.setAudioSamplingRate(48000);
mRecorder.setAudioEncodingBitRate(96000);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(TAG, "unable to prepare MediaRecorder");
mRecorder = null;
return;
}
mRecorder.start();
mRecording = true;
setState(STATE_RECORDING);
} else {
mRecorder.stop();
mRecorder.release();
mRecording = false;
setState(STATE_IDLE);
}
}
示例10: 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;
}
}