I'm using JSR 135 to play an audio file. This is the way I'm doing it.
InputStream is = getClass().getResourceAsStream("/tone.mp3");
Player p = Manager.createPlayer(is, "audio/mp3");
p.start();
// get volume control for player and set volume to max
VolumeControl vc = (VolumeControl) p.getControl("VolumeControl");
if (vc != null) {
vc.setLevel(100);
}
p.close();
p = null;
is.close();
is = null;
But I need the audio to always play through the loudspeaker of the phone. In this moment, if I plugin a headset, the sound will only play in the earpiece. Is there a way to achieve this?