Android的 - 将音频通过扬声器播放 [英] Android - Getting audio to play through speakers

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

问题描述

我想打的MP3音频文件,使用相同的扬声器和音量当用户接到一个电话。
我使用下面的code

I would like to play a mp3 audio file with the same speaker and volume when an user receive a phone call. I am using the following code

int result = audioManager.requestAudioFocus(afChangeListener,
                    AudioManager.MODE_IN_CALL,
                    AudioManager.AUDIOFOCUS_GAIN);
audioManager.setSpeakerphoneOn(true);

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 

在清单

,但它不工作。体积是非常高的。
任何想法?

but it does not work. the volume is very high. Any idea?

推荐答案

什么是调用 setSpeakerPhoneOn (最有可能)会做的是路线既音乐和声音打电话到扬声器,在这种情况下,它们可能会被混合在一起,并在音乐可以被下采样到语音呼叫采样速率(8位或16千赫)。

What that call to setSpeakerPhoneOn (most likely) will do is to route both the music and the voice call to the loudspeaker, in which case they might be mixed together and the music may be downsampled to the voice call sample rate (8 or 16 kHz).

有一件事你可以尝试是我在<提议href=\"http://stackoverflow.com/questions/12036221/how-to-turn-speaker-on-off-programatically-in-android-4-0\">how打开扬声器/关闭编程中的Andr​​oid 4.0
这可以让你让你的路线只有音乐的扬声器,而语音通话的音频被路由到耳机。它不能保证,虽然在所有设备上工作。

One thing you could try is what I proposed in how to turn speaker on/off programatically in android 4.0 This could let you let you route only the music to the loudspeaker while voice call audio is routed to the earpiece. It's not guaranteed to work on all devices though.

这篇关于Android的 - 将音频通过扬声器播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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