如何使用Android的PJSUA2管理音频输出级别 [英] How do I manage the audio output levels with PJSUA2 for Android
问题描述
我有一个Android项目,该项目使用PJSUA2进行VoIP通信,其他一切都很好.但是,我受困于一个问题,即我无法让音量"控件在显示我的活动呼叫的活动"中工作.我尝试过推荐的方法-
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);
这什么也没做.我需要知道是否可以使用OnKey Listeners来手动增加和减小音量,或者是否完全缺少某些东西,这将使我以首选方式进行操作.
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.
推荐答案
当呼叫处于连接状态时,您必须将音频模式设置为MODE_IN_COMMUNICATION
,并在断开连接时将其设置为MODE_NORMAL
.
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);
这篇关于如何使用Android的PJSUA2管理音频输出级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!