I am implementing Text to speech feature for my android application. I know Text to Speech will user STREAM_MUSIC as default stream. When i invoke Text to Speech it is speaking with expected volume. But i am wondering, when i invoke Text to Speech if there is any ongoing calls in device will result my Speech with low volume. I am not understanding how it is happening. Phone call will user AudioManager.STREAM_VOICE_CALL. Will it effect AudioManager.STREAM_MUSIC volume?
I want to play my speech with default volume even if there is any ongoing call in phone.
Please any one can guide me to understand these AudioManager streams which will effect by which and how.
Here is my text to speech invoking method
private void speakMessage(String audibleString){
tTts.speak(audibleString, TextToSpeech.QUEUE_ADD, null);
}
Thanks in advance
What you are experiencing is called audio ducking. It is an operation performed automatically by the OS (or sometimes another app) when another audio source obtains focus (similar to how a view obtains focus). Only one audio source can have focus at a time. When another audio source obtains focus, current audio sources may be ducked (quieted), paused or left alone. You can use the
AudioManager
to request thatSTREAM_MUSIC
be given focus with requestAudioFocus().Edit: Additional info on audio focus.