无法在Android 12上录制语音通话。

huangapple go评论59阅读模式
英文:

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&lt;AudioRecordingConfiguration&gt;?) {
                   super.onRecordingConfigChanged(configs)
                   configs?:return

                   configs.forEach {

                       LogUtil.d(&quot;isClientSilenced=${it.isClientSilenced} \n&quot; +
                               &quot;devices=$${it.audioDevice.address} \n&quot; +
                               &quot;effect=${it.effects.size} \n&quot; +
                               &quot;format=${it.format} \n&quot; +
                               &quot;audioSource=${it.audioSource}&quot;)
                   }

               }
           })
           try {
               prepare()
           } catch (e: IOException) {
               LogUtil.d(&quot;prepare() failed&quot;)
           }
           LogUtil.d(&quot;start record&quot;)
           start()
       }

The isClientSilenced method always returns true during voice calls, even if you are using AccessibilityService

to record voice calls

答案1

得分: 0

最后,我发现我必须使用VOICE_RECOGNITION模式,并且只有在不使用耳机时才能录音通话。

英文:

In the end, I discovered that I must use the VOICE_RECOGNITION mode, and recording calls is only possible when not using headphones.
无法在Android 12上录制语音通话。

huangapple
  • 本文由 发表于 2023年7月13日 17:51:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678072.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定