How to change the audio output from speaker phone to earpiece in flutter android?

Viewed 1264

I'm using flutter_webrtc package for audio call functionality of my app and by default the audio output is on speakerphone how can I change the speaker phone to earpiece in flutter.

By analysing the code I used this method which is method in RTCVideoRenderer class called audioOutput but it throws unImplementedError.

1 Answers

You must use the enableSpeakerphone method in the MediaStreamTrack class like this

android manifest

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
currentRender.srcObject?.getAudioTracks()[trackIndex].enableSpeakerphone(boolean);

Related