Javascript to detect system volume (sound) and audio jack connected to

HTML5 has a built-in volume definition.

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

This is for the player only.

Is it possible to determine the volume from the system? Tell the phone. Can I get voluminous data of my phone from a mobile browser?

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

Can I determine the volume level for audio output using GetUserMedia?

+6
source share
1 answer

The short answer is no! This is how web browsers have been made for a very long time, and Microsoft / Google / Apple / Mozilla / Opera did this to avoid exploits through File.IO, etc. In fact, we should be grateful for this - because it isolates your computer (with all your personal data) from the web application (which can be hosted on the server with hostile intentions).

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

Thus, this cannot be done with HTML5 / Javascript - just think of the browser as the operating system your web application is running on. Therefore, Google, Microsoft, etc. + The rest of the people who decide HTML5 standards are those who decide how much access a developer gets. Camera hardware, GPS equipment, etc. We get access, but we are not allowed to do whatever we want with this equipment - this is not always the choice of developers.

+1
source

Source: https://habr.com/ru/post/976123/


All Articles