Forked from abbasnaqdi/high_quality_media_recorder.kt
Created
October 28, 2018 19:31
-
-
Save realmahdi/1b1a1e1a363135e511f634e0bdae1116 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
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
// 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