Javascript检测系统的音量(声音)和插入的音频插孔 [英] Javascript to detect system's volume (sound) and audio jack plugged in

查看:653
本文介绍了Javascript检测系统的音量(声音)和插入的音频插孔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML5具有板载音量检测功能。

HTML5 has an onboard volume detection.

<video controls width="320" height="176" onvolumechange="alert('The volume has been changed')">

这仅适用于玩家。

是否可以从系统中检测音量?说一个电话。我可以通过手机浏览器获取手机的音量读数吗?

Is it possible to detect volume from the system? Say a phone. Can I get volume readings of my phone from the mobile browser?

或者我可以使用JS来检测音频插孔是否已插入?

Or can I use JS to detect if the audio jack is plugged in?

可以检测音量级别使用GetUserMedia进行音频输出?

Can Volume level be detected for audio out using GetUserMedia?

推荐答案

对此的简短回答是否定的!
这就是网络浏览器很长一段时间以来的制作方式,而Microsoft / Google / Apple / Mozilla / Opera这样做是为了避免通过File.IO等进行攻击。实际上,我们应该感谢这一点 - 因为它将您的计算机(包括所有个人资料)与网络应用程序隔离(可能托管在具有恶意意图的服务器上)。

Short answer for this is no! This is how web-browsers have been made for a very long time now, and Microsoft/Google/Apple/Mozilla/Opera have done this to avoid exploits through File.IO and such. Actually, we should be thankful for this - as it isolates you computer (with all your personal stuff) from the web-application (which might be hosted on a server with hostile intentions).

实际上,有一种方法可以做到这一点,但它只适用于IE用户 - 答案是activeX插件。现在,你可以让你的javascript创建这样一个插件并与之通信 - 但是谁知道IE将来是否会支持activeX。

Actually, there is one way you could do this, but it would only work for IE users - and the answer is activeX plugins. Now, you could make your javascript create such a plugin and communicate with it - but who knows if activeX will be supported by IE in the future.

因此,单凭HTML5 / Javascript无法实现这一点 - 只需将浏览器视为运行Web应用程序的操作系统。因此谷歌,微软等以及决定HTML5标准的其他人是决定开发者获取多少访问权限的人。相机硬件,GPS硬件等我们可以访问,但我们不允许用硬件做任何我们想做的事 - 它并不总是开发人员的选择。

So per se, there is no way this is achievable with HTML5/Javascript alone - just think of the browser as the OS on which your web-app is running. So Google, Microsoft etc + the rest of the people who decides the HTML5 standards are the ones who decides how much access the developer gets. Camera hardware, GPS hardware etc. we do get to access, but we are not allowed to do whatever we want with that hardware - its not always the developers choice.

这篇关于Javascript检测系统的音量(声音)和插入的音频插孔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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