如何在 pjsip android 应用程序中启用扬声器? [英] How to enable speaker in pjsip android app?

查看:40
本文介绍了如何在 pjsip android 应用程序中启用扬声器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 pjsip 应用程序中使用扬声器,所以我使用的是 setOutputRoute:

I am trying to use the speaker in my pjsip app, so I am using setOutputRoute:

pjmedia_aud_dev_route route=pjmedia_aud_dev_route.PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER;MyApp.ep.audDevManager().setOutputRoute(route, true);

pjmedia_aud_dev_route route=pjmedia_aud_dev_route.PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER; MyApp.ep.audDevManager().setOutputRoute(route, true);

但我收到一个错误:无效或不受支持的音频功能 (PJMEDIA_EAUD_INVCAP).

but I am getting an error: invalid or unsupported audio capability (PJMEDIA_EAUD_INVCAP).

在 pjsua 中它说:此方法仅当设备在 AudioDevInfo.caps 标志中具有 PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE 功能时才有效,否则将抛出错误.

In pjsua it says: This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE capability in AudioDevInfo.caps flags, otherwise Error will be thrown.

我在想也许我必须设置这个标志......但我不知道如何

I am thinking maybe I have to set this flag... But I don't know how

推荐答案

几天前我遇到了同样的问题.我知道这不是答案,只是一个替代方案,但我最终使用了它并且效果很好.

I ran into the same problem some days ago. I know its not the answer, just an alternative but I ended up using this and it works good.

AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setSpeakerphoneOn(true);

我使用 Android AudioManger 通过调用 setSpeakerOn() 在听筒和扬声器之间切换.如果您使用它,请注意,如果您切换输出,其设置将永久对应于上下文.您可以通过调用 audioManager.isSpeakerphoneOn() 获取当前状态.

I used the Android AudioManger to toggle between the Earpiece and the Speaker by calling setSpeakerOn(). If you use it be aware that if you toggle the output its set permanently corresponding to the context. You can get the current state by calling audioManager.isSpeakerphoneOn().

这篇关于如何在 pjsip android 应用程序中启用扬声器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆