Created
August 8, 2014 15:59
-
-
Save j-onathan/3c6f38b703aa7f7508db to your computer and use it in GitHub Desktop.
Android Code Example: Recording audio and video (from https://www.codota.com/android/scenarios/52fcbdf8da0aff1c35670032/recording-audio-and-video?tag=dragonfly)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void startRecording(String file){ | |
if (!isRecording){ | |
saveFile=file; | |
recorder = new MediaRecorder(); | |
recorder.setAudioSource(MediaRecorder.AudioSource.MIC); | |
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); | |
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); | |
recorder.setOutputFile(this.recording); | |
try { | |
recorder.prepare(); | |
} catch (IllegalStateException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} catch (IOException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
isRecording = true; | |
recorder.start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment