1

Can anyone please show me how and where can I modify the Phonegap source to play audio through the earpiece?

dda
  • 6,030
  • 2
  • 25
  • 34
Martin Ongtangco
  • 22,657
  • 16
  • 58
  • 84

1 Answers1

2

Try this code:

private AudioManager m_amAudioManager;  
m_amAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);  
m_amAudioManager.setMode(AudioManager.MODE_IN_CALL); 
m_amAudioManager.setSpeakerphoneOn(false); 

Also need to add new permission:

MODIFY_AUDIO_SETTINGS

Either put this code in your activity start (onCreate()) or you need to write a plugin to enable/disable it based on your requirement from the javascript.

Check this post for more Android - Getting audio to play through earpiece

Community
  • 1
  • 1
dhaval
  • 7,611
  • 3
  • 29
  • 38