How to play sound in ear speaker in xamarin android? - android

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.

Related

(android) How to detect if phone is muted while ringing

I am trying to develop an android application which requires detection of if phone is muted during an incoming call is active(ringing). Some phones have a mute button which instantly mute the sound of the call but does not stop the call (phone is ringing in silent).
Before the call, phone is not muted, but when the call begins, user decides to mute the phone with this button. I want to determine if this situation is happened or not.
I tried to read RINGER_MODE_CHANGED_ACTION but it seems that this button does not change the RINGER_MODE(Maybe I am wrong).
So how can I do that?

Pause/Stop/Mute music at service interupts

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.

Should Games request Audio Focus on Android?

I have been reading the Android documentation on "Audio Focus", and the best-practices they lay out, but one thing alludes me...
Games need music pretty much the whole time, so it makes sense to request Audio Focus OnStart, but this can lead to a bad user experience.
If my App requests Audio Focus, and something is currently playing music already (eg. Samsung Music Player), my request will forcefully stop their music. The only special case I know of is if you request Audio Focus while the user is in a Phone Conversation.
I think what the user expects to happen, is if they are not already listening to music (or podcast, or whatever), then the game music should play. However, if they are already listening to their own music, then the game should not play music (but still play sound effects).
This is how things work on Xbox, Windows Phone, PS3, etc.
Is this just how it is on Android? Has anyone come up with a nice work around?
Note: I am familiar with AudioManager.IOnAudioFocusChangeListener. I am speaking specifically about the initial request for Audio Focus.
The other special case to avoid stopping something from playing when requesting audio focus is to allow it to duck, but that applies to transient loss which isn't what you would be doing. There's no way to know if another app is playing audio unfortunately so you will either take the audio and kill the music or you can not request the audio and hope for the best.
It might be worth prompting the user on launch if they are listening to their own music and if so then your game music will remain silent.

Android media player not producing sound even playing

I have created a media player application using Android MediaPlayer API. The app is working fine unless a phone call is received. I am handling phone call events in my app and doing pause and play of media player.
The problem is that After pause and play, when phone call arrives, the song is playing but with no sound from speakers.
One more thing is This is happening when I am using bluetooth headset only.
If anybody faced this problem, please reply suggestions to my question.
I solved this problem by stopping bluetooth's SCO before playing a music track if it is ON.

How to play audio file when call starts?

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

Categories

Resources