通过扬声器在Android中强制声音输出 [英] Forcing sound output through speaker in Android

查看:3138
本文介绍了通过扬声器在Android中强制声音输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Android中强制通过手机扬声器输出,即使耳机插入插孔?我知道必须有一种方法,因为当你在电话中说,你可以把手机喇叭人,即使有耳机插入插孔。

Is there a way in Android to force output through the phone speaker, even if a headphone is plugged into the jack? I know there has to be a way because when you are talking on the phone, you can put someone on speaker phone, even if there is headphones plugged into the jack.

推荐答案

您可以更改这个系统范围内使用<一个href="http://developer.android.com/reference/android/media/AudioManager.html#setSpeakerphoneOn(boolean)"相对=nofollow> AudioManager.setSpeakerphoneOn 的方法。

You can change this system-wide using the AudioManager.setSpeakerphoneOn method.

我不相信你可以设置为一个特定的的MediaPlayer / AudioTrack / 的Soundpool 实例,但是这取决于你的使用情况,您的也许的实际使用看的 MediaPlayer.setAudioStreamType 或等价物等音频格式播放类。

I don't believe you can set this for a particular MediaPlayer/AudioTrack/SoundPool instance, but depending on your use case, you might actually be looking to set your audio stream type using MediaPlayer.setAudioStreamType or an equivalent for other audio playback classes.

这篇关于通过扬声器在Android中强制声音输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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