Play的Android设备的音频低谷手机喇叭 [英] Play audio trough phone speaker of an android device
问题描述
是否可以播放音频低谷Android设备的手机喇叭?
产生与你的耳朵对着手机上市紧密时,只能听到一个低容量声音的手机内的小喇叭。
希望我的描述是不够清楚明白我的问题。
如果这是可能的,如何做到这一点为例将是非常有益的。
修改
目前我使用以下code初始化我的MediaPlayer。
的MediaPlayer =新的MediaPlayer();
mediaPlayer.setOnBufferingUpdateListener(本);
mediaPlayer.setOnCompletionListener(本);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
mediaPlayer.setDataSource(audioPath);
媒体播放器prepare()。
如果您希望通过听筒播放音频,使用的 STREAM_VOICE_CALL
流类型。如果您使用的MediaPlayer
类有一个<一个href=\"http://developer.android.com/reference/android/media/MediaPlayer.html#setAudioStreamType%28int%29\"相对=nofollow> setAudioStreamType
方法,您可以使用此目的,并为 AudioTrack
类传递流类型为<一个href=\"http://developer.android.com/reference/android/media/AudioTrack.html#AudioTrack%28int,%20int,%20int,%20int,%20int,%20int%29\"相对=nofollow>构造。
Is it possible to play audio trough the phone speaker of an android device? The smaller speaker inside a phone that produces a low volume sound which can only be heard when listing closely with your ear against the phone.
Hopefully my description is clear enough to understand my question.
If it is possible, a example for how to accomplish this would be really helpful.
EDIT Currently i'm using the following code to initialize my MediaPlayer.
mediaPlayer = new MediaPlayer();
mediaPlayer.setOnBufferingUpdateListener(this);
mediaPlayer.setOnCompletionListener(this);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
mediaPlayer.setDataSource(audioPath);
mediaPlayer.prepare();
If you want to play audio through the earpiece, use the STREAM_VOICE_CALL
stream type. If you use the MediaPlayer
class there's a setAudioStreamType
method that you can use for this purpose, and for the AudioTrack
class you pass the stream type to the constructor.
这篇关于Play的Android设备的音频低谷手机喇叭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!