21

The question have been asked before ( How to play an audio file on a voice call in android, play an audio file on a voice call etc), but I will ask it anyway: Is it possible to play an audio file into an ongoing voice call. I know the short answer is "No", but I have not figured out why it is not possible.

I know the SDK does not have support for it, but would it by any chance be possible in some way to write your own code that handles this, maybe with help from C/C++ code (using the NDK)? Does anyone have any idea on how to solve this? Or is the answer a strict "no, you cannot play pre-recorded audio into a voice call"?

I do not really care if the solution does not work on all devices, as long as I can find some devices that support the solution, and I can consider the get root access if that is needed.

W. Churchill
  • 346
  • 1
  • 7
  • 28
user675862
  • 241
  • 2
  • 6
  • with root access + NDK it is definitely possible... but i would recommend not to go down that route... – Yahia Mar 19 '12 at 19:28
  • Ok, thanks for your comment. I will look into to the problem a bit before I give up. Right now I am looking at the OpenSLES API and if it is possible in some way to change OutputMix/OutputDevice. – user675862 Mar 20 '12 at 13:20
  • @user675862 Have you found any solution to this ? – Hunt Apr 09 '12 at 18:38
  • @Yahia , do you know any other alternative to implement this solution – Hunt Apr 09 '12 at 18:57
  • @Hunt as I wrote above: with root access + NDK it is definitely possible... but i would recommend not to go down that route... – Yahia Apr 09 '12 at 19:00
  • @Yahia , is there any specific reason not to dig down to route ? – Hunt Apr 09 '12 at 19:03
  • @Hunt several: any new version of Android would need lots of testing/modifying... you can't install it on every phone (only on "rooted" ones)... depeding on the specific HW it might even work unreliably... – Yahia Apr 09 '12 at 19:08
  • 3
    I haven't found a general solution, but I noticed that it is possible to do on Nexus S and Galaxy Nexus. Just use AudioTrack in the SDK and use STREAM_VOICE_CALL as streamType. This approach doesn't work on other phone I've tested (HTC Desire and some SE phones) – user675862 Apr 10 '12 at 07:38
  • @user675862: If your requirement is to mix secondary audio along with the existing Voice call app (Sim calls), I dont think there is any generic solution other than modifying the android source for that device. I had done a similar implementation for a particular android device (OMAP4 based). Here i modified the AudioFlinger library. However if you are developing your own voice calling app with mixing feature, you can always mix the pcm signals by using a simple adder . You may need a C function and JNI for this though. – Shrish Jan 18 '15 at 16:58
  • I've done this on some Qualcomm-based devices. See e.g. http://stackoverflow.com/questions/14432521/background-music-for-call/14433414#14433414 and http://stackoverflow.com/questions/15204570/inject-uplink-audio-in-call-with-snapdragon-msm8960-soc/15205455#15205455. As far as I know you'd only be able to use that approach on rooted devices. – Michael Mar 25 '15 at 09:56
  • @user675862 Have you found any solution to this ? – Ravi Patil Mar 23 '18 at 04:37
  • try with tasker? – A P Mar 26 '22 at 15:44
  • I want to play an audio file on a call when the mic is muted so the person on other side just can hear the played audio no the person. Is it possible or not? – Fahime Ghasemi Jul 23 '22 at 07:23

1 Answers1

-1

I used Audiotrack to play audio with stream set to STREAM_VOICE_CALL during voice call on my One-Plus(Test Device) and it worked perfectly, however the audio which I speak is heard clearly and the music played is not heard. Probably because of the noise cancellation feature applied. I used Lollipop based Rom for this.So the answer is yes we can play.

Saurav
  • 560
  • 4
  • 17
  • The question is about playing music during a voice call so that it's heard at the far end (i.e. by the other party of the call), not about local playback that only you can hear. The latter case is supported by most devices I've worked with. – Michael Mar 25 '15 at 10:00
  • "The question is about playing music during a voice call so that it's heard at the far end" playing music at originator side and listening at receiver side right ? @Michael – Saurav Mar 25 '15 at 10:14
  • excellent can you share some code i am trying to create a module in which audio stream must be inserted.. – Vivek Nov 27 '18 at 13:41