I am initiating a voice call from my application. Now i want that when the user on the other side picks up the call, i want to play a recorded audio file.
How to go about this? Please help!
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.
Open File Manager and navigate to the folder where the audio file is located. Drag the audio file icon from File Manager and drop it on the Audio main window. The Selected file is opened. If Automatically play audio file on Open is selected in the Options-Play dialog box, the audio file starts playing.
To play audio or video files in Android, the Android multimedia framework includes the support of MediaPlayer APIs. So, by using MediaPlayer APIs, you can play audio/video files from your Android filesystem or play files from your Application's resource file or even you can stream audio/video files just like Spotify.
During a call, the other party listens to your voice through the microphone. When the music is played through the phone, due to Android limitations, the sound output cannot be recorded or shared directly. The music can be shared only through your microphone input.
I have found a workaround with this. I play an audio file on device's speakers with full sound when the phone state changes to TelephonyManager.CALL_STATE_OFFHOOK
This ensures that the user on the other side can hear the recording.
In simple and clear words you cant stream any sound on an Incoming call
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With