英文:
Unable to record voice calls on Android 12
问题
recorder = MediaRecorder().apply {
setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION)
setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP)
setOutputFile(fileName)
setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB)
registerAudioRecordingCallback(executor, object : AudioManager.AudioRecordingCallback() {
override fun onRecordingConfigChanged(configs: MutableList<AudioRecordingConfiguration>?) {
super.onRecordingConfigChanged(configs)
configs ?: return
configs.forEach {
LogUtil.d("isClientSilenced=${it.isClientSilenced} \n" +
"devices=${it.audioDevice.address} \n" +
"effect=${it.effects.size} \n" +
"format=${it.format} \n" +
"audioSource=${it.audioSource}")
}
}
})
try {
prepare()
} catch (e: IOException) {
LogUtil.d("prepare() failed")
}
LogUtil.d("start record")
start()
}
The isClientSilenced method always returns true during voice calls, even if you are using AccessibilityService to record voice calls.
英文:
recorder = MediaRecorder().apply {
setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION)
setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP)
setOutputFile(fileName)
setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB)
registerAudioRecordingCallback(executor,object:
AudioManager.AudioRecordingCallback() {
override fun onRecordingConfigChanged(configs: MutableList<AudioRecordingConfiguration>?) {
super.onRecordingConfigChanged(configs)
configs?:return
configs.forEach {
LogUtil.d("isClientSilenced=${it.isClientSilenced} \n" +
"devices=$${it.audioDevice.address} \n" +
"effect=${it.effects.size} \n" +
"format=${it.format} \n" +
"audioSource=${it.audioSource}")
}
}
})
try {
prepare()
} catch (e: IOException) {
LogUtil.d("prepare() failed")
}
LogUtil.d("start record")
start()
}
The isClientSilenced method always returns true during voice calls, even if you are using AccessibilityService
to record voice calls
答案1
得分: 0
最后,我发现我必须使用VOICE_RECOGNITION模式,并且只有在不使用耳机时才能录音通话。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论