Indicator of web-connected headphones

2

How can I know if I have headphones connected to my computer? My goal is to get it using HTML5 + JavaScript.

The next page shows all the audio output devices, but there is no way to know if the active device is about headphones or not.

link

The only thing I want to know is if there are headphones connected with JavaScript and HTML5.

    
asked by Miguel Bastida 07.10.2016 в 12:53
source

1 answer

3

There is no way to know this because the JavaScript API for interaction with the OS is limited. To this day, you can only know the devices available on your computer, but not the connected .

The example you have made uses the new audio web API that is still in development and, what it does, is to list the audio / video devices available on the computer.

navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
  devices.forEach(function(device) {
    // tienes acceso a:
    // device.kind
    // device.label
    // device.deviceId
  });
});
    
answered by 07.10.2016 / 15:12
source