How to mute audio in headset but let it play on speaker programmatically?

前端 未结 2 1183
深忆病人
深忆病人 2020-12-01 22:44

I am searching a work-around for my problem specified in this question:

How to disable the wired headset programmatically in Java

As mentioned there, I am ge

相关标签:
2条回答
  • 2020-12-01 23:27

    AudioManager mAudioMgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE); mAudioMgr.setSpeakerphoneOn(true); mAudioMgr.setMode(AudioManager.MODE_IN_COMMUNICATION);

    0 讨论(0)
  • 2020-12-01 23:33
    AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
    am.setMode(AudioManager.MODE_IN_CALL);
    am.setSpeakerphoneOn(true);
    

    And then play the sound through the AudioManager.STREAM_SYSTEM stream.

    When the sound's finished playing be sure to return the audio manager to its previous state or it'll stay on loudspeaker!!

    0 讨论(0)
提交回复
热议问题