16

I'm trying to make and app like Call Cheater(Originally developed for Symbian OS)

Is it possible to play a music during a phone conversation where receiver and caller should hear the same sound or music?

If yes how can I implement this?

1
  • 1
    When I make calls I can hear Notification's sounds of another apps. May be this way with increased volumes is implemented?
    – Tapa Save
    Jan 19, 2015 at 12:17

7 Answers 7

14
+150

You failed to find an app that does this because it is not possible.

The documentation clearly states (here):

Note: You can play back the audio data only to the standard output device. Currently, that is the mobile device speaker or a Bluetooth headset. You cannot play sound files in the conversation audio during a call.

The reason behind this decision has probably something to do with security: there are several scenarios where this capability could be used for cons.

(the OP is highly similar to this, hence I'm basically giving the same answer)

5
  • Then howcome in some Nokia Low end Symbian OS based phones can play songs that the other party can also hear. I mean in android too I can play audio during call, it's possible and I am doing it, the only problem is the OTHER PARTY is not able to hear that audio. Jan 16, 2015 at 5:37
  • What the documentation states and means is exactly what you are saying: you won't be able to play a sound that is both heard by you and the other party.
    – Sebastiano
    Jan 16, 2015 at 7:46
  • There's second answer to this question stating that it an be done, but their is some echoing problem. Please comment on that. Jan 16, 2015 at 9:49
  • As the user said, it's an ugly kludge. The other party will totally hear that the audio is not "clean" but it is rather coming from an outside source. Not what you want, I assume.
    – Sebastiano
    Jan 16, 2015 at 11:09
  • 3
    @XeeMezAsHu People who don't understand the problem and hand out downvotes due to their lack of understanding is what makes me hate StackOverflow. Downvote if the answer is wrong, not because you don't want to hear the truth. There are a couple of wonky apps that "play hold music" using exactly the strategy I described, and honestly, their efforts are laughable.
    – MarsAtomic
    Jan 18, 2015 at 3:09
4

Two answers, both valid, depending on how sloppy you like to be:

1) No, it's not currently possible to inject audio into a phone conversation.

2) Yes, it's possible. It's also an ugly, ugly kludge. Turn on the hands free function of your phone. Create a media player, set the media source, set the volume to 1.0f (highest) and call player.start(). If the microphone and speakers on the phone are of reasonable quality, the other party to the call will hear the music. He or she will also continue to hear anything you say, as well as ambient and other sounds in your immediate vicinity.

2
  • Is it possible to make the volume of the device louder when i am on a call? I mean when i receive the call automatically the volume of the music becomes softer.Is there any way to keep the volume unchanged?
    – Developer
    Jun 25, 2013 at 8:56
  • @B770, seems that echo cancellation is a problem.
    – kagali-san
    Jan 3, 2014 at 4:56
2

I think this is possible in one case

1.Some of the native music players in android device where handling this,they restrict the music when call is in TelephonyManager.EXTRA_STATE_OFFHOOK (OFFHOOK STATE) so there is no way of playing the background music using native players and some other players like "poweramp music palyer"

2.By using the MediaPlayer class also it is not possible(clearly mentioned in documentation)

3.It is possible only in one case if your developing custom music player(with out using MediaPlayer class) in that implements

AudioManager.OnAudioFocusChangeListener by using this you can get the state of the audiomanager in the below code "focusChange=AUDIOFOCUS_LOSS_TRANSIENT"(this state calls when music is playing in background any incoming call came) this state is completely in developers hand whether to play or pause the music. As according to your requriment as for question you asked if you want to play the music when call is in OFFHOOK STATE dont pause playing music in OFFHOOK STATE .And this is only possible when headset is disabled

AudioManager am = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
     
    OnAudioFocusChangeListener afChangeListener = new OnAudioFocusChangeListener() {
        public void onAudioFocusChange(int focusChange) {
            if (focusChange == AUDIOFOCUS_LOSS_TRANSIENT
                // Pause playback (during incoming call) 
            } else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) {
                // Resume playback (incoming call ends)
            } else if (focusChange == AudioManager.AUDIOFOCUS_LOSS) {
                am.unregisterMediaButtonEventReceiver(RemoteControlReceiver);
                am.abandonAudioFocus(afChangeListener);
                // Stop playback (when any other app playing music  in that situation current app stop the audio)
            }
        }
    };
1
  • I tried this link but dint work. Any idea why so. Able to play audio with code on click of some button but not while on call.
    – Jaikrat
    Oct 3, 2015 at 12:04
2

No, It is not possible. But if you want to dig it more, then you can visit Using Android phone as GSM Gateway for VoIP where author has concluded that

It's not possible to use Android as a GSM Gateway in its current form. Even after flashing custom ROM because they also depends on proprietary RIL (Radio Interface Layer) firmwares. Hurdles 1 and 2 (API limitation) can be removed because the source code is available for the open source community to make it possible. However, the hurdle 3 (proprietary RIL) is dependent on the hardware vendors. Hardware vendors do not usually make their device drivers code available.

0
Note: You can play back the audio data only to the standard output device.
Currently, that is the mobile device speaker or a Bluetooth headset. You 
cannot play sound files in the conversation audio during a call.

See official link 

http://developer.android.com/guide/topics/media/mediaplayer.html

0

I think it's not possible. Though I found an app from google play called PHONE MUSIC which claims to : "Thus whenver someone puts you on hold just hit the hovering musical note and start playing music. Or play music while someones on the phone with you. "

0

Yes it is possible in Sony ericssion xylophone w20 .I have got this phone in 2010.but yet this type of phone I have not seen.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.