Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting Chrome Media Settings in Javascript

Chrome has recently released an update to its media settings which prompts a user to grant permission to a site allowing access to his/her microphone and camera. Is there a way to detect these settings in Javascript?

I have a flash player (which will eventually be HTML5 based) with microphone functionality. The player is currently set up with a friendly tutorial on how to grant permission before starting the session. However, since Chrome released the update, the flash player and Chrome permissions are conflicting causing an error in the flash until the user has allowed/denied the Chrome settings prompt. What I'd like to do, until the player is moved to HTML5, is detect if the browser is Chrome (with appropriate version) and if the user's settings aren't set to then show additional tutorial screen.

like image 794
SirTophamHatt Avatar asked Aug 14 '26 07:08

SirTophamHatt


1 Answers

Couple things:

  • This is specific to Chromes implementation so you can not tell what permissions the user has granted unless Chrome supplies that information to your app. I.E. there is no API you can query for this info.
  • It's not even something that Chrome stores. If you look under the advanced settings tab on this page, you will see that its on a per app basis not a one time thing. Chrome will only remember what permission was granted for a specific application if that app asks for the permission over https. If it asks for it over http then it will forget what permissions were granted.

Your best bet (though by no means full-proof) is to sniff out the browser agent and version. For one of the better implementations of this see here.

You will want to specifically look for Chrome and any version >= 21. (21 was the version that introduced the getMediaApi). Then it's a simple if check:

if (version >= 21){
    //ask permission though the getMediaApi 
} else{
    //ask permission though flash
}
like image 182
Ryan Avatar answered Aug 16 '26 21:08

Ryan