Android - Play audio from earpiece

后端 未结 7 2005
旧巷少年郎
旧巷少年郎 2020-12-02 08:27

I\'d like to play audio from a file into the phone\'s earpiece (or headset of that is connected) using the android MediaPlayer. I tried using the MODE_IN_CALL h

7条回答
  •  囚心锁ツ
    2020-12-02 09:03

    This method is working fine for me.

    You need to set audio manager mode too. and then using audiomgr.setSpeakerphoneOn(false) api you can toggle.

    AudioManager audiomgr = (AudioManager) 
        context.getSystemService(Context.AUDIO_SERVICE);
    audiomgr.setMode(AudioManager.MODE_IN_COMMUNICATION);
    audiomgr.setSpeakerphoneOn(false);
    

提交回复
热议问题