How can I capture the AudioDestinationNode value when headphones are plugged in with Web Audio API?

Deadly 提交于 2019-12-23 02:21:22

问题


I've been looking for a solution that detects the difference between the default speakers and headphones on a computer. I understand that with Web Audio API, AudioDestinationNode represents the output device, where users hear audio.

My question (to be specific) is whether or not it is possible to detect a change in the users' audio output device (wired/wireless headphones). If this is not possible, is there a way to use phonegap to do so, for computers as well as mobile devices?

My goal is to initiate an event only when the AudioDestinationNode maps to headphones or external speakers.


回答1:


There's nothing in the Web Audio API spec for this.

It might be possible in Phonegap (at least if you were willing to write your own Phonegap plugin) – but that's only going to help on mobile. As far as I know, there's no way to determine the audio output device in any of the major desktop browsers.

Just out of curiosity, what are you hoping to do as a result of the user switching between built-in speakers and an external device?



来源:https://stackoverflow.com/questions/26074400/how-can-i-capture-the-audiodestinationnode-value-when-headphones-are-plugged-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!