Skip to content

Instantly share code, notes, and snippets.

@abbasnaqdi
Last active October 28, 2018 19:31
Show Gist options
  • Save abbasnaqdi/0a901b3b1bab9e528f77994335e63413 to your computer and use it in GitHub Desktop.
Save abbasnaqdi/0a901b3b1bab9e528f77994335e63413 to your computer and use it in GitHub Desktop.
The MediaRecorder formula is compatible with various Android versions and high-quality audio recorder, Tested on Android 21 to 28
// The MediaRecorder formula is compatible with various Android versions and high-quality audio recorder,
// Tested on Android 21 to 28
mediaRecorder = MediaRecorder().apply {
setAudioSource(MediaRecorder.AudioSource.MIC)
setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC)
setOutputFile(filePath)
setAudioEncodingBitRate(320000)
setAudioSamplingRate(96000)
}
mediaRecorder?.apply {
prepare()
start()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment