Michal Dobrodenka
Michal Dobrodenka

Reputation: 1134

How to set type to my audio so it will be treated like a call?

I'm making VoIP app on Android, playing PCM audio like in Play PCM stream in Android

On my phone (LG V20, Android8) it works, but when I'm using volume buttons, it doesn't show Call volume and volume control doesn't work for my audio at all.

How to make my audio "Call audio" and be controlled by standard volume controls?

Upvotes: 0

Views: 349

Answers (2)

Michal Dobrodenka
Michal Dobrodenka

Reputation: 1134

In the end, I was missing:

  1. Permission - MODIFY_AUDIO_SETTINGS
  2. Setting AudioManager mode to MODE_IN_COMMUNICATION

I'm surprised it wasn't in tutorials, maybe it was changed in later SDK.

Upvotes: 0

emandt
emandt

Reputation: 2716

You have to take AudioFocus by calling "requestAudioFocus()": https://developer.android.com/reference/android/media/AudioManager#requestAudioFocus(android.media.AudioFocusRequest) and set VOICECALL Stream in the Constructor of the Request.

Upvotes: 1

Related Questions