3

Chrome or CEF3 should not use the default speaker of the system to play the sound (audio out). Is there any way that user or developer can set default speaker in chrome or CEF3 other than system default?

e.g during WebRTC call, (in current scenario) audio sound is used to play by default audio sound device (speaker). But in my scenario it should be played by selected speaker not system default.

phil652
  • 1,484
  • 1
  • 23
  • 48
KrishPS
  • 145
  • 2
  • 10

2 Answers2

0

This feature is not available in Chrome/Chromium/CEF.

Also, in Windows there is no public API to set which sound card use for output (it is left to the user to choose that):

This is a deliberate design, since we do not want applications to override audio setting set by the user

...However, here are some workarounds:

https://stackoverflow.com/a/2216886/833188

https://stackoverflow.com/a/20270535/833188

Community
  • 1
  • 1
Sga
  • 3,608
  • 2
  • 36
  • 47
  • No, the question is not how to change the default sound card, it's how to output to a different one. – Brad Apr 15 '18 at 22:59
0

You should be able to do this purely in the JavaScript side of your application without having to mess with the CEF side. First, find what device ID you want to output to:

const devices = await navigator.mediaDevices.enumerateDevices();
const audioDevices = devices.filter(device => device.kind === 'audiooutput');

audioDevices will now contain all outputs. Then, set your Audio object's sink:

const audio = document.querySelector('audio');
audio.setSinkId(audioDevices[0].deviceId);

For more information: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId

Brad
  • 159,648
  • 54
  • 349
  • 530