我如何知道我是否已将耳机连接到计算机?HTML5 + JavaScript [英] How I can know if I have headphones connected to my computer? HTML5 + JavaScript

查看:73
本文介绍了我如何知道我是否已将耳机连接到计算机?HTML5 + JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何知道我是否已将耳机连接到计算机?我的目标是使用HTML5 + JavaScript来获得它.

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

在下一页上显示所有音频输出设备,但是无法知道活动设备是否是耳机.而且在Firefox中不起作用!

On the next page shows all audio output devices, but there is no way of knowing if the active device is a headphonet or not. And in Firefox it doesn't work!

https://webrtc.github.io/samples/src/content/devices/input-output/

我只想知道我是否有耳机与HTML5和JavaScript连接.

All I want to know is if I have headphones connected with HTML5 and JavaScript.

推荐答案

无法使用任何现有的API,但是一种方法可以是在检查麦克风是否拾起声音的同时发出声音.

There is no way using any existing API, but one way could be to send a sound out while checking if the microphone picks it up.

这将是对回声的真实测试,您可以使用一些欢迎"声音和一些FFT代码来解析"麦克风输入,并查看您发送的声音是否正在重新进入麦克风.但是,这需要进行一些微调才能使其可靠,并且仍然不会使扬声器上的音量较小的人或​​耳机音量太大的人..即使在这种情况下,由于他们在产生回音,因此很可能会被他们抓住.做正确的事.

This would be a real test for echo, you could use some "welcome" sound and some FFT code to "parse" microphone input and see if the sound you are sending is re-entering the microphone. However it would require quite some fine tuning to be reliable, and will still not catch people with low volume on the speakers or catch people with too loud headphones .. even if, in that case, since they are producing echo, catching them is probably the right thing to do.

我不记得哪个会议软件实际上在执行此设置步骤,发出旋律并检查反馈(也许是Skype的早期版本?),但是在现代浏览器中是可行的.

I can't remember which conferencing software was actually doing this setup step emitting a melody and checking the feedback (maybe it was Skype early versions?), but it's doable in modern browsers.

这篇关于我如何知道我是否已将耳机连接到计算机?HTML5 + JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆