3

How does one enable webrtc with geckofx?

I've tried

        var perm = Xpcom.CreateInstance<nsIPermissionManager>("@mozilla.org/permissionmanager;1");
        nsIURI pwcom = Xpcom.CreateInstance<nsIIOService>("@mozilla.org/network/io-service;1").NewURI(new nsAUTF8String("https://apprtc.appspot.com"), null, null);
        perm.Add(pwcom, "camera", 1, 0, 0);
        perm.Add(pwcom, "video-capture", 1, 0, 0);
        perm.Add(pwcom, "audio-capture", 1, 0, 0);

To give permission to site to use getUserMedia, but still can't use any webrtc demo sites (such as https://apprtc.appspot.com)

I'm using GeckoFX 29.0.10

PS I've included an nsIConsoleListener which only emits

2014-11-10 214218 consoleListener.Observe: [JavaScript Error: "TypeError: window.arguments is undefined" {file: "chrome://global/content/alerts/alert.js" line: 42}]

2014-11-10 214219 consoleListener.Observe: [JavaScript Error: "NS_ERROR_NOT_IMPLEMENTED: " {file: "chrome://global/content/alerts/alert.js" line: 77}]

Is the alert.js used for the prompt requesting which device to use for webrtc?

Benjamin Trent
  • 7,378
  • 3
  • 31
  • 41
Demur Rumed
  • 421
  • 6
  • 17

1 Answers1

8

This works for me:

Gecko.Xpcom.Initialize(@"******************");
GeckoPreferences.User["plugin.state.flash"] = true;
GeckoPreferences.User["browser.xul.error_pages.enabled"] = true;
GeckoPreferences.User["media.navigator.enabled"] = true;
/* The following line is the key: */
GeckoPreferences.User["media.navigator.permission.disabled"] = true;

By disabling the navigator permission, it automatically accepts the request, without poping up the dialog.

Test code:

GeckoWebBrowser myBrowser = new GeckoWebBrowser();
this.Controls.Add(myBrowser);
myBrowser.Dock = DockStyle.Fill;

myBrowser.Navigate("http://davidwalsh.name/demo/camera.php");

Greetings,

Daniel

MartoniczD
  • 178
  • 1
  • 1
  • 9
  • Many thanks for this Daniel - saved me a lot of hassle! – hynsey Jul 15 '15 at 12:33
  • 1
    are you aware of how to choose which camera is used here, rather than the default one? Since we are suppressing the dialogue in the browser, I need a way to tell it which one to use (I can have the user select a camera in a different section of my application outside this browser). I'm hoping there's a setting within the group of `media.navigator` options you've detailed above, but can't find any references to the available options online. – hynsey Jul 15 '15 at 12:55
  • Ok I got a list of all options, by navigating to `about:config`. However I can't find anything which looks like it can control which Webcam device to use. – hynsey Jul 15 '15 at 13:56