使用Web Audio API插入耳机时,如何捕获AudioDestinationNode值? [英] How can I capture the AudioDestinationNode value when headphones are plugged in with Web Audio API?

查看:151
本文介绍了使用Web Audio API插入耳机时,如何捕获AudioDestinationNode值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找能够检测计算机上默认扬声器和耳机之间差异的解决方案。据我所知,使用Web Audio API,AudioDestinationNode代表用户听到音频的输出设备。

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.

我的问题(具体)是否可以检测用户音频输出设备(有线/无线耳机)的变化。如果这是不可能的,有没有办法使用phonegap这样做,对于计算机和移动设备?

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?

我的目标是仅在AudioDestinationNode映射到耳机或外部扬声器。

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

推荐答案

Web Audio API规范中没有任何内容。

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

在Phonegap中可能有可能(至少如果你愿意编写自己的Phonegap插件) - 但这只会对移动设备有所帮助。据我所知,没有办法在任何主要的桌面浏览器中确定音频输出设备。

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?

这篇关于使用Web Audio API插入耳机时,如何捕获AudioDestinationNode值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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