使用耳机和扬声器同时 [英] simultaneously using a headphone and speaker

查看:382
本文介绍了使用耳机和扬声器同时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想同时使用的耳机插孔,方便不同的音频输出/输入使用扬声器音频输出。这可能吗?

I'd like to use the speaker for audio output while simultaneously using the headphone jack for a different audio output/input. Is this possible?

推荐答案

这是可能的做的部分的设备(我已经验证了它的工作原理上的索尼Xperia P),但我不'认为你能指望它来工作的所有的设备。

It's possible to do on some devices (I've verified that it works on a Sony XPeria P), but I don't think you can count on it to work on all devices.

什么,你会做的就是力量音乐流路由到扬声器:

What you'd do is force MUSIC streams to route to the loudspeaker:

Class audioSystemClass = Class.forName("android.media.AudioSystem");
Method setForceUse = audioSystemClass.getMethod("setForceUse", int.class, int.class);
// First 1 == FOR_MEDIA, second 1 == FORCE_SPEAKER. To go back to the default
// behavior, use FORCE_NONE (0).
setForceUse.invoke(null, 1, 1);

然后使用音乐流为任何你想要的路由到扬声器,而 VOICE_CALL 流什么你想送到耳机/耳机。

Then you use the MUSIC stream for anything you want routed to the loudspeaker, and the VOICE_CALL stream for anything you want routed to the headset/headphones.

请参阅我的<一个答案href="http://stackoverflow.com/questions/12017297/playing-sound-over-speakers-while-playing-music-through-headphones/12018786#12018786">Playing声音在播放音乐的扬声器通过耳机

这篇关于使用耳机和扬声器同时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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