[英]How to play the audio file in android using mediaplayer when screen sleeps
[英]how to play audio via ear phones only using mediaplayer android
有誰知道如何在設備的聽筒或耳塞中播放音軌?
我用了這個:
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();
但是什么也沒發生。 有人可以給我打電話嗎?
剛在2.2上運行。 我仍然需要我不太喜歡的In_Call設置,但我現在要處理。 我能夠拋棄現在不推薦使用的呼叫路由功能。 我發現您絕對需要Modfiy_Audio_Settings權限,沒有它就沒有錯誤,但是setSpeackerPhone方法什么也沒做。 這是我使用的代碼的模擬。
private AudioManager m_amAudioManager;
m_amAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
m_amAudioManager.setMode(AudioManager.MODE_IN_CALL);
m_amAudioManager.setSpeakerphoneOn(false);
Curtsy:Android- 通過聽筒播放音頻
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.