-1

I am looking for a way to play an audio message to recipient of a phone call as soon as he/she receives the call. I want to push my audio when someone receives the call and then I start conversation. Example:- When some organization calls they start with a greetings audio message first then start the actual conversation.

I have tried searching a lot but all the questions related to this on Stackoverflow are bit old and they mention that this is not possible. Is it still the case?

Could someone please guide how one could achieve this in android?

  • Does this answer your question? [Inject audio into voice stream in android](https://stackoverflow.com/questions/24018722/inject-audio-into-voice-stream-in-android) – Markus Kauppinen Feb 14 '20 at 08:31

1 Answers1

-1

You can play and control the audio files in android with the help of the MediaPlayer class.

MediaPlayer: This class is the primary API for playing sound and video. AudioManager: This class manages audio sources and audio output

Simply you can use MediaPlayer and play the audio file. Check out this nice example for playing Audio. How to play audio in android..

 public void audioPlayer(String path, String fileName){
    //set up MediaPlayer    
    MediaPlayer mp = new MediaPlayer();

    try {
        mp.setDataSource(path + File.separator + fileName);
        mp.prepare();
        mp.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Zia
  • 705
  • 9
  • 11