本文整理了Java中android.media.MediaRecorder.start()
方法的一些代码示例,展示了MediaRecorder.start()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MediaRecorder.start()
方法的具体详情如下:
包路径:android.media.MediaRecorder
类名称:MediaRecorder
方法名:start
暂无
代码示例来源:origin: stackoverflow.com
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
mRecorder.prepare();
mRecorder.start();
mRecorder.stop();
mRecorder.release();
mRecorder = null;
代码示例来源:origin: stackoverflow.com
MediaRecorder mRecorder = new MediaRecorder();
File mFile = new File("The output file's absolutePath");
... //config the mRecorder
mRecorder.setOutputFile(mFile.getAbsolutePath());
... //prepare() ...
mRecorder.start();
try {
mRecorder.stop();
} catch(RuntimeException e) {
mFile.delete(); //you must delete the outputfile when the recorder stop failed.
} finally {
mRecorder.release();
mRecorder = null;
}
代码示例来源:origin: stackoverflow.com
public class Call extends BroadcastReceiver{
private MediaRecorder mRecorder;
public void onReceive(Context context, Intent intent){
//...
if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)){
mRecorder = new MediaRecorder();
mRecorder.start();
//....
}
if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_IDLE)){
if(mRecorder!=null){
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
}
}
}
代码示例来源:origin: commonsguy/cw-omnibus
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setOutputFile(getStreamFd());
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioChannels(2);
recorder.prepare();
recorder.start();
recorder.stop();
代码示例来源:origin: stackoverflow.com
MediaRecorder mRecorder = new MediaRecorder();
File mFile = new File("The output file's absolutePath");
... //config the mRecorder
mRecorder.setOutputFile(mFile.getAbsolutePath());
... //prepare() ...
mRecorder.start();
try {
mRecorder.stop();
} catch(RuntimeException e) {
mFile.delete(); //you must delete the outputfile when the recorder stop failed.
} finally {
mRecorder.release();
mRecorder = null;
}
代码示例来源:origin: stackoverflow.com
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(audiofile.getAbsolutePath());
try {
recorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
e.printStackTrace();
recorder.start();
recordstarted = true;
Toast.makeText(context, "REJECT || DISCO", Toast.LENGTH_LONG).show();
if (recordstarted) {
recorder.stop();
recordstarted = false;
代码示例来源:origin: guardianproject/haven
final MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setOutputFile(audioPath.toString());
try {
recorder.prepare();
} catch (Exception e){
e.printStackTrace();
recorder.start();
try {
Thread.sleep(prefs.getAudioLength());
recorder.stop();
Log.i("AudioRecorderTask", "Stopped recording");
recorder.release();
代码示例来源:origin: commonsguy/cw-omnibus
BASENAME);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setOutputFile(output.getAbsolutePath());
recorder.prepare();
recorder.start();
recorder.stop();
代码示例来源:origin: commonsguy/cw-omnibus
void start() {
recorder=new MediaRecorder();
recorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoFrameRate(config.frameRate);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
recorder.setVideoSize(config.width, config.height);
recorder.setVideoEncodingBitRate(config.bitRate);
recorder.setOutputFile(output.getAbsolutePath());
try {
recorder.prepare();
vdisplay=projection.createVirtualDisplay("andcorder",
config.width, config.height, config.density,
VIRT_DISPLAY_FLAGS, recorder.getSurface(), null, null);
beeper.startTone(ToneGenerator.TONE_PROP_ACK);
recorder.start();
}
catch (IOException e) {
throw new RuntimeException("Exception preparing recorder", e);
}
}
代码示例来源:origin: stackoverflow.com
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
recorder = new MediaRecorder();
initRecorder();
setContentView(R.layout.main);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
.get(CamcorderProfile.QUALITY_HIGH);
recorder.setProfile(cpHigh);
recorder.setOutputFile("/sdcard/videocapture_example.mp4");
recorder.setMaxDuration(50000); // 50 seconds
recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
recorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
recorder.stop();
recording = false;
} else {
recording = true;
recorder.start();
recorder.stop();
recording = false;
代码示例来源:origin: stackoverflow.com
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(audioDirTemp + "/audio_file"
+ ".mp3");
recorder.prepare();
recorder.start();
isRecording = true; // we are currently recording
} catch (IllegalStateException e) {
handler.removeCallbacks(updateVisualizer);
visualizerView.clear();
recorder.stop();
recorder.reset();
recorder.release();
代码示例来源:origin: stackoverflow.com
private SurfaceHolder surfaceHolder;
private SurfaceView surfaceView;
public MediaRecorder mrec = new MediaRecorder();
private Button startRecording = null;
mrec.stop();
mrec.release();
mrec = null;
mrec = new MediaRecorder(); // Works well
mCamera.unlock();
mrec.setAudioSource(MediaRecorder.AudioSource.MIC);
mrec.setOutputFile("/sdcard/zzzz.3gp");
mrec.prepare();
mrec.start();
mrec.stop();
mrec.release();
mCamera.release();
代码示例来源:origin: stackoverflow.com
mediaRecorder = new MediaRecorder();
camera.unlock();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mediaRecorder.setOutputFile(
Environment.getExternalStorageDirectory()+"/"+
DateFormat.format("yyyy-MM-dd_kk-mm-ss", new Date().getTime())+
);
try { mediaRecorder.prepare(); } catch (Exception e) {}
mediaRecorder.start();
public void onDestroy() {
mediaRecorder.stop();
mediaRecorder.reset();
mediaRecorder.release();
代码示例来源:origin: stackoverflow.com
} else
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
if (!rUncompressed)
mediaRecorder.setOutputFile(filePath);
mediaRecorder.prepare();
state = State.READY;
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.start();
mediaRecorder.stop();
代码示例来源:origin: chat-sdk/chat-sdk-android
public File record(String name) {
stopRecording();
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath() + AudioMessageDirectory + File.separator;
File file = new File(path);
file.mkdir();
path += name;
Timber.v("Recording to: " + path);
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setOutputFile(path);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
try {
recorder.prepare();
} catch (IOException e) {
ChatSDK.logError(e);
}
recorder.start();
startTime = System.currentTimeMillis();
return new File (path);
}
代码示例来源:origin: dkim0419/SoundRecorder
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);
if (MySharedPreferences.getPrefHighQuality(this)) {
mRecorder.setAudioSamplingRate(44100);
mRecorder.setAudioEncodingBitRate(192000);
}
try {
mRecorder.prepare();
mRecorder.start();
mStartingTimeMillis = System.currentTimeMillis();
//startTimer();
//startForeground(1, createNotification());
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
}
代码示例来源:origin: Piasy/RxAndroidAudio
stopRecord();
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(audioSource);
mRecorder.setOutputFormat(outputFormat);
mRecorder.setAudioSamplingRate(sampleRate);
mRecorder.setAudioEncodingBitRate(bitRate);
mRecorder.setAudioEncoder(audioEncoder);
mRecorder.setOutputFile(outputFile.getAbsolutePath());
mRecorder.prepare();
} catch (IOException | RuntimeException exception) {
Log.w(TAG, "startRecord fail, prepare fail: " + exception.getMessage());
mRecorder.start();
mStarted = true;
} catch (RuntimeException exception) {
代码示例来源:origin: stackoverflow.com
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(output_formats[currentFormat]);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(getFilename());
recorder.setOnErrorListener(errorListener);
recorder.setOnInfoListener(infoListener);
recorder.prepare();
recorder.start();
} catch (IllegalStateException e) {
e.printStackTrace();
recorder.stop();
recorder.reset();
recorder.release();
代码示例来源:origin: stackoverflow.com
setContentView(R.layout.activity_main);
mMediaRecorder = new MediaRecorder();
mMediaRecorder.start();
mMediaRecorder.stop();
mMediaRecorder.reset();
mMediaRecorder.prepare();
} catch (Exception e) {
e.printStackTrace();
int height = mDisplayMetrics.heightPixels;
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoSize(width, height);
mMediaRecorder.setOutputFile(filePath);
mMediaRecorder.start();
代码示例来源:origin: stackoverflow.com
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
recorder = new MediaRecorder();
initRecorder();
setContentView(R.layout.main);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
.get(CamcorderProfile.QUALITY_HIGH);
recorder.setProfile(cpHigh);
recorder.setOutputFile("/sdcard/videocapture_example.mp4");
recorder.setMaxDuration(50000); // 50 seconds
recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
recorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
recorder.stop();
recording = false;
} else {
recording = true;
recorder.start();
recorder.stop();
recording = false;
内容来源于网络,如有侵权,请联系作者删除!