How do I manage the audio output levels with PJSUA2 for Android

喜你入骨 提交于 2020-01-15 05:27:26

问题


I have an Android project that uses PJSUA2 for VoIP communication and everything else works just fine. I am stymied however, with a problem where I cannot get the Volume controls to work in the Activity where my active call is shown. I have tried doing it the recommended way -

audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
setVolumeControlStream(AudioManager.STREAM_MUSIC);

This doesn't do anything. I need to know if using OnKey Listeners is a feasible alternative to manually increase and decrease the volume or if I am missing something completely which will let me do it the preferred way.


回答1:


When call is in connected state you have to set audio mode to MODE_IN_COMMUNICATION and set to MODE_NORMAL on disconnect.

// set mode to 3 to indicate MODE_IN_COMMUNICATION mode
((AudioManager) getSystemService(Context.AUDIO_SERVICE)).setMode(3);
// set audio mode to normal again on call disconnection
((AudioManager) getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_NORMAL);



回答2:


So I finally figured out the way to do this reasonably with PJSUA was to implement my own keypress handler and then vary the Rx Audio Levels accordingly. Hope this helps someone who was stuck as bad as I was.



来源:https://stackoverflow.com/questions/42263070/how-do-i-manage-the-audio-output-levels-with-pjsua2-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!