private fun getRecorder(absoluteOutFilePath: String, audioSource: Int): MediaRecorder {
val mediaRecorder = MediaRecorder()
mediaRecorder.setAudioSource(audioSource)
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC)
mediaRecorder.setAudioEncodingBitRate(64000)
mediaRecorder.setAudioSamplingRate(16000)
audioManager.mode = AudioManager.MODE_IN_CALL
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL), 0)
mediaRecorder.setOutputFile(absoluteOutFilePath)
mediaRecorder.prepare()
mediaRecorder.start()
return mediaRecorder
}
所以我尝试记录对话
val mediaRecorder = try {
getRecorder(absoluteOutFilePath, MediaRecorder.AudioSource.VOICE_CALL)
}catch (e:Exception){
Log.w("Can't start record with AS VOICE_CALL, try set AS MIC")
getRecorder(absoluteOutFilePath, MediaRecorder.AudioSource.MIC)
}
一切正常,异常不会下降。但是,当我用 SGS8 录制时,它被使用了MIC
,因为。当VOICE_CALL
抛出异常时:java.lang.RuntimeException: start failed
。
我发现三星设备上的通话录音似乎不适用于所有国家/地区。同时,PlayGoogle 中有各种应用程序(例如,这个)可以完美地记录这台设备上的对话。解释如何在此设备和类似设备上正确记录通话,如何绕过此限制?