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!
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
Related
I'm doing a cross platform app in visual studio, I want to know how to play sound in ear speaker, like mobile ringing sound while we make a call, can any one help me for this?
UPDATE
Actually I was trying to do SIP calling. I have used Android.Net.Sip. I can able to call to SIP Numbers but before pick the call from end user the ring sound cant be ringing in my mobile.
Its having this functions but I cant able hear ring sound
//Called when a RINGING response is received for the INVITE request sent.
public override void OnRingingBack(SipAudioCall call)
{
base.OnRingingBack(call);
}
for this I was tried to play ring sound using media player, but this will use loud speaker, for this I want to play ring sound in ear speaker or can we can able play ring sound using above functions. can any one help me for this?
No need to restart your phone. Just close the running apps and try the audio. It'll be normal, through your main speaker. I've observed one thing. While the music is coming through ear speaker just make a call, that automatically pauses the playing audio, and in the call put on the loud speaker and now go to the music player (don't disconnect the call, let it go in speaker mode) and turn on the music, now the audio will get out through main speaker in normal way. Again putting off the speaker mode of the current going call throw back the audio to ear speaker. After disconnecting that call also the audio will play through ear speaker only. I don't know the reason behind this. This is just my observation. Finally I would like to conclude that, no need to restart your phone. Just close the running apps (all) and now try the audio. It'll be fine.
I basically have an audio application that will be playing some music. I want to be able to pause/stop/mute the music when there is an interrupt.
These interrupts include: GPS directions, Phone Call, GPS, etc. (if there are more audio interupts, please let me know)
I already implemented the phone call interrupt, stops the music when phone call received and plays after phone call ends.
How would I do the other interrupts?
EDIT:
I noticed that Android's Play Music application does this. But I am unable to find the source code of that, not sure if that would be helpful.
Make sure you correctly ask for and release Audio Focus as described here:
http://developer.android.com/training/managing-audio/audio-focus.html
With multiple apps potentially playing audio it's important to think about how they should interact. To avoid every music app playing at the same time, Android uses audio focus to moderate audio playback—only apps that hold the audio focus should play audio.
Basically this allows the framework to handle interrupts properly as you cannot specifically code for every situation.
You can make a new call on Android OS with a certain contact. But I want to play(stream) certain sound file instead of a microphone. I just want to play sound for callee although caller doesn't hear anything.
Is there any solution?
I am writing a android app which is supposed to play back a audio file when a call is in progress coming from a specific number .. I tried many approaches.. but all went in vein
Separate Thread
Listener on Telephone service
starting a service in parallel
can any one please help me how to proceed regarding this ?
Update :
I am able to play a mp3 file on call recieve and i am able to play it load on speaker.. but how ever loud i play the calling party is not able to listen to it.... is there anyway i can push the speaker stream to call stream
From the api doc 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.
So from this and lots of other so answers we can conclude that we can not play an audio during a call process.
But a long time ago from a personal experience with a handset I got a result where the audiotrack was playing while there was a call established and both the voices were heard at the same time. So I think this depends on handsets if it allows it then you can play.
You can try another thing experimentally. play the audio using a different route ( speakerphone or bluetooth).
Another option is to build your custom android build
Actually i am creating an application which starts recording when user start speaking and
stop recording automatically when user stop speaking.
so is there any way to find if user is speaking or not?
is there any listener for Media Recorder for this?
No, AFAIK there are no listeners or intents that would notify your app that sound level has gone above some threshold (e.g. user started talking).
You could use AudioRecord class to record the microphone audio and then analyze it to see the volume. However this would require your app to run at that time.