Reputation: 75296
I'm writing an Android application that plays back voice mails using MediaPlayer, which are just WAV files that have been sent to the device. When I play the file, it's played on the device's speaker, or else it plays through headphones if they're plugged in.
What I want to do is play the file so that it sounds to the user as if it's at the same volume level as a normal phone call. Is there a way to route playback so that the file is played through the phone's earpiece instead of out of the speaker?
Upvotes: 2
Views: 1532
Reputation: 75296
The answer is to use the AudioManager
class:
http://developer.android.com/reference/android/media/AudioManager.html
setSpeakerphoneOn(false)
is what you need to call to route the audio to the earpiece.
Edit: except is doesn't seem to actually have any effect on anything. That's irritating.
Upvotes: 2
Reputation: 94
Try using MediaPlayer.setAudioStreamType()
to set the playback stream to AudioManager.STREAM_VOICE_CALL
.
Upvotes: 3