angularagora.ioagora-web-sdk-ng

Agora audio call use loud speaker how to switch to earspeaker in angular


I used this js code in my Angular project to initiate audio-video calls using Agora: https://github.com/divanov11/Voice-Chat-Rooms/blob/master/1-Basic-Voice-Chat/main.js

I have successfully converted the js code to Angular, and it is functioning properly. However, I am currently facing an issue. I am attempting to switch from loudspeaker to ear speaker on a mobile browser, but I am unable to find any Angular-specific guidance for this. Most of the available help pertains to Android or iOS platforms. Now on audio call voice is coming from speaker not from ear speaker.

I try to search on Agora but only got information about enableAudioVolumeIndicator but i want to switch loud speaker to ear speaker special on audio call.

Before voting negative on this question please try to find solution and share the url then vote it negative.


Solution

  • Initially, I assumed that mobile browsers would behave similarly to iOS and Android apps, allowing us to switch between the ear speaker and loudspeaker programmatically. I was searching for code to achieve this but couldn't find any. Eventually, I stumbled upon this link, which demonstrates that if the mobile device permits speaker changes through the browser, you can test it.

    However, it seems that most devices do not allow speaker changes from a mobile browser

    I found this which confirms that mobile browsers do not support changing speakers like ios or android; please give this a try: https://webrtc.github.io/samples/src/content/devices/input-output/

    If you're unable to find a solution, consider not marking this answer negatively.