I want to play an audio file let's say from the loudspeakers and by the use of a button change it to built-in loudspeakers and vice versa. A built-in loudspeaker could be a headset, a bluetooth device. But let's consider for simplicity the built-in loudspeakers.
I'm doing the following thing:
Initialise the player with appropriate context and uri and then
asyncPlayer.play(context, uri, true, st);
where st I have seen it takes the values STREAM_VOICE_CALL, STREAM_MUSIC, STREAM_RING, STREAM_NOTIFICATION
I have noticed that when I use the
audioManager.setSpeakerphoneOn(true/false);
This works only when the st value is STREAM_VOICE_CALL. For STREAM_RING I could do the same only my changing the mode, i.e.
audioManager.setMode(AudioManager.MODE_NORMAL);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
To be honest I find it a little bit counter-intuitive as I would expect that with any file I would be able to set the Speakerphone on and off without changing the mode...
Could you give me some indications on how it works, or any other suggestions?
The reason I'm using the asyncPlayer is because I want to do at the same time other things as well.
Thanks