在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):WindSekirun/NaraeAudioRecorder开源软件地址(OpenSource Url):https://github.com/WindSekirun/NaraeAudioRecorder开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):NaraeAudioRecorderAudioRecorder for Android powered by Kotlin. Key Features
ImportIt distributed on JCenter, but sometime it's not available.
CoreCore module will contain most feature and two format. 'pcm' and 'wav'
FFmpeg-RecorderFFmpeg-Recorder will contain five format, 'mp3', 'm4a', 'wma', 'flac', 'aac' This module will increase Final APK Size about 20MB. You can reduce APK Size by this guide
UsagesCoreInitialization val audioRecorder = NaraeAudioRecorder()
val destFile = File(Environment.getExternalStorageDirectory(), "/NaraeAudioRecorder/$fileName$extensions")
audioRecorder.create() {
this.destFile = destFile
} Define instance of 'NaraeAudioRecorder' and create file and provide with If you want use NoiseSuppressor, define instance of val recordConfig = AudioRecordConfig.defaultConfig()
val audioSource = NoiseAudioSource(recordConfig)
audioRecorder.create() {
this.destFile = this.destFile
this.recordConfig = recordConfig
this.audioSource = audioSource
} Initialization in JavaThis is full sample of 'initialization in Java'. other feature is same. File destFile = new File(getContext().getExternalFilesDir(null) + String.format("/recorder/%s.mp3", fileName));
destFile.getParentFile().mkdirs();
mAudioRecorder.checkPermission(getContext());
mAudioRecorder.create(FFmpegRecordFinder.class, config -> {
config.setDestFile(destFile);
config.setDebugMode(true);
config.setTimerCountListener((currentTime, maxTime) -> {
});
return null;
});
FFmpegAudioRecorder ffmpegAudioRecorder = (FFmpegAudioRecorder) mAudioRecorder.getAudioRecorder();
ffmpegAudioRecorder.setContext(getContext());
ffmpegAudioRecorder.setOnConvertStateChangeListener(state -> {
if (state == FFmpegConvertState.SUCCESS) {
mRecordedPath = destFile.getPath();
}
}); PermissionStarting from 1.2.0, if permission isn't granted, NaraeAudioRecorder will throw RuntimeException.
So make sure grant proper permissions before using Start / Stop / Pause / ResumeaudioRecorder.startRecording(Context)
audioRecorder.stopRecording()
audioRecorder.pauseRecording()
audioRecorder.resumeRecording() Custom config of AudioRecordYou can custom config of fun defaultConfig() = AudioRecordConfig(MediaRecorder.AudioSource.MIC,
AudioFormat.ENCODING_PCM_16BIT,
AudioFormat.CHANNEL_IN_MONO,
AudioConstants.FREQUENCY_44100) Listen about state changes of recordaudioRecorder.setOnRecordStateChangeListener(OnRecordStateChangeListener) Set maxAvailableTime & Listen about changes of timeraudioRecorder.create(FFmpegRecordFinder::class.java) {
...
this.maxAvailableMillis = TimeUnit.SECONDS.toMillis(20)
this.timerCountListener = { currentTime, maxTime -> }
} If you want use accuracy, define FFmpeg-recorderUsing FFmpeg-recorder will need some additional info. audioRecorder.create(FFmpegRecordFinder::class.java) {
this.destFile = this.destFile
this.recordConfig = recordConfig
this.audioSource = audioSource
}
val ffmpegAudioRecorder: FFmpegAudioRecorder = audioRecorder.getAudioRecorder() as? FFmpegAudioRecorder ?: return
ffmpegAudioRecorder.setContext(this) In parameters of FFmpeg-recorder uses Change config of FFmpegYou can custom config of FFmpeg using this options. ffmpegAudioRecorder.setConvertConfig(FFmpegConvertConfig) Default value is Listen about state changes of convertffmpegAudioRecorder.setOnConvertStateChangeListener(OnConvertStateChangeListener) Sample ApplicationLicenseCore
FFmpeg-recorder |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论