[英]how to play audio via ear phones only using mediaplayer android
Anyone know how to play audio track in ear piece or ear speaker of the device?? 有谁知道如何在设备的听筒或耳塞中播放音轨?
I have used this: 我用了这个:
AudioManager audio_service = (AudioManager) getSystemService
(Context.AUDIO_SERVICE);
// set the mode in call, so that the sound can come from earpiece
audio_service.setSpeakerphoneOn(false);
audio_service.setMode(AudioManager.MODE_IN_CALL);
audio_service.setRouting(AudioManager.MODE_NORMAL,
AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
mediaplayer.start();
but nothing happened..:| 但是什么也没发生。 Can anyone tel me?
有人可以给我打电话吗?
Just got it to work on 2.2. 刚在2.2上运行。 I still needed the In_Call setup which I don't really like but I'll deal with it for now.
我仍然需要我不太喜欢的In_Call设置,但我现在要处理。 I was able to ditch the call routing stuff which is deprecated now.
我能够抛弃现在不推荐使用的呼叫路由功能。 I found you defenitly need the Modfiy_Audio_Settings permission, no error without it but it the setSpeackerPhone method just does nothing.
我发现您绝对需要Modfiy_Audio_Settings权限,没有它就没有错误,但是setSpeackerPhone方法什么也没做。 Here is the mock up of the code I used.
这是我使用的代码的模拟。
private AudioManager m_amAudioManager;
m_amAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
m_amAudioManager.setMode(AudioManager.MODE_IN_CALL);
m_amAudioManager.setSpeakerphoneOn(false);
Curtsy : Android - Getting audio to play through earpiece Curtsy:Android- 通过听筒播放音频
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.