Is it possible to play music during calls so that the partner can hear it ? Android

后端 未结 7 586
猫巷女王i
猫巷女王i 2020-12-31 08:24

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 call

相关标签:
7条回答
  • 2020-12-31 08:48

    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 讨论(0)
  • 2020-12-31 08:58

    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.

    0 讨论(0)
  • 2020-12-31 09:02

    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)

    0 讨论(0)
  • 2020-12-31 09:06

    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)
                }
            }
        };
    
    0 讨论(0)
  • 2020-12-31 09:07

    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 讨论(0)
  • 2020-12-31 09:07
    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 讨论(0)
提交回复
热议问题