W
W
WebDev2019-10-03 00:41:40
JavaScript
WebDev, 2019-10-03 00:41:40

How to select speaker on phone using JavaScript?

I am making a hybrid application in which you can call via webrtc. I stream audio and play it through the audio tag. Everything is fine and works, but in the mobile phone the sound goes through the speakerphone. Is it possible to make the sound go through a standard speaker (I don’t know what it’s called correctly) or at least make a switch for a speakerphone?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Bratukhin, 2019-10-03
@kirill-93

Purely theoretically, this is possible through enumerateDevices() and further use of deviceId in setSinkId(), but in practice it does not work everywhere. For example, in the latest Chrome for Android, I have only one output device in the list. Here is an article on the topic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question