问题描述
我想同时使用的耳机插孔,方便不同的音频输出/输入使用扬声器音频输出。这可能吗?
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.
请参阅我的Playing声音在播放音乐的扬声器通过耳机
这篇关于使用耳机和扬声器同时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!