LingoRecorder: Seamlessly Capturing Sound on Android

In the realm of Android development, capturing sound effortlessly yet efficiently remains a significant endeavour. The "lingorecorder" library, conceived by huangweijun, arises as a beacon of simplicity and power for this very task. Crafted with the finesse of Kotlin and under the liberal auspices of the Apache 2.0 license, "lingorecorder" opens a vista of opportunities for developers to embed audio recording functionality in their Android applications.

Embarking on the "lingorecorder" voyage requires a simple addition to your project's dependencies:

dependencies {
  implementation 'com.github.huangweijun:lingorecorder:1.0.0'
}

Initiating a recording session is no more complex than a few lines of code:

val recorder = LingoRecorder(context)

// Configure recording parameters
recorder.setAudioFormat(AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_IN_MONO, 44100)

// Commence recording
recorder.start()

Once your audio capture is complete, retrieving and playing back the audio file is straightforward:

// Conclude recording and obtain the audio file
val audioFile = recorder.stop()

// Playback the recorded audio
val player = MediaPlayer()
player.setDataSource(audioFile.path)
player.prepare()
player.start()

The "lingorecorder" library does not merely stop at basic recording but extends its capabilities to customization, allowing for a tailored recording experience:

// Customize recorder attributes
recorder.setMaxDuration(10000)
recorder.setOnRecordListener {
  // Actions during recording
}
recorder.setOnStopListener {
  // Actions post recording
}