Background music for call [closed]

放肆的年华 提交于 2019-11-27 04:34:38

Some mobile platforms do support this functionality at the platform-level (e.g. I've tested this with the Qualcomm APQ8064 where I had configured the hardware codec route accordingly, and it works). But Android doesn't have an API that let's you use this as an app developer, so on a non-rooted phone there's not really anything you can do.
Why there's no API for it - or whether there will be one in coming versions of Android - I don't know. There might be legal issues in some markets, or it might just be because it's considered as a semi-obscure feature that they don't see a great demand for and which is supported only by a relatively small number of platforms.

Another thing to consider is, do you really want to have music playing in the background during a call?
The audio is going to be 8 kHz mono (or 16 kHz mono if you're in a wideband call), and it's going to be AMR-encoded along with the rest of the speech signal (AMR is a low-bitrate codec designed for encoding speech). In other words, any music you play over the voice call uplink is going to sound really, really bad.

UPDATE: For APQ8064-based phones where you have root access, the procedure would be something like this (I don't remember the exact syntax off the top of my head):

audioManager.setParameters("incall_music_enabled=true");

// Execute the following using e.g. Runtime.exec()
amix 'SLIMBUS_4_RX Audio Mixer MultiMedia2' 1
aplay -Dhw:0,1 mono_8khz_data.pcm

// When you want to stop music playback, stop the aplay process, and then do
audioManager.setParameters("incall_music_enabled=false");

currently there is no way to do this as the hardware does not support it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!