7

There have been some buzz in the air for the WebRTC support in Firefox 22. This is for someone who's in the know about Firefox development: Are there any support in Firefox for desktop screen capture todate?

The technology does exist for Chrome 26+, which provides experimental support for screen capturing (using 'screen' as device source); the code (snippet) for making this happen is:

   // select any supported getUserMedia function
   navigator.getMedia = (navigator.getUserMedia || 
                         navigator.webkitGetUserMedia ||
                         navigator.mozGetUserMedia ||
                         navigator.msGetUserMedia);

  // if getUserMedia is not supported, do nothing 
  if( !navigator.getMedia ) return;

  // request for user media
  navigator.getMedia(
  {
     video : {
        mandatory : {
           // request 'screen' as a source media
           chromeMediaSource : 'screen'
        }
     }
  },

  // success
  function( localMediaStream )
  {
     // process local media stream...
  },

  // failure
  function( error )
  {
     // error handling
  });

Looking at W3C docs, the objects MediaSourceConstraints, MediaTrackConstraints, MediaTrackConstraintsSet have not yet been standardized. It might simply be that the API is all too foggy for this feature to appear in Firefox production. It would just be good to know the current state of support.

Alexander O'Mara
  • 58,688
  • 18
  • 163
  • 171
knight
  • 300
  • 2
  • 7

2 Answers2

4

No, Firefox hasn't yet added screensharing like Chrome: https://bugzilla.mozilla.org/show_bug.cgi?id=742832

tomtheengineer
  • 4,127
  • 1
  • 17
  • 15
4

This is now possible in Firefox, however due to security concerns, support is hidden behind some preferences. Specifically the media.getusermedia.* preferences under about:config.

This comment on a Mozilla bug report illustrates some of those concerns:

Now that we've redesigned <input type="file"> to not draw the full path on the screen, things are better. We still have problems with things like drawing cross-origin images and <iframe>s.

Even with user opt-in, I'd worry about situations like "user loads app page A in one tab and app page B in another tab, page B asks for permission to screen-share page A which looks fine, user accepts, then app swaps an <iframe> of FB or gmail or whatever into page A and grabs the contents.

Though media.getusermedia.screensharing.enabled is currently true by default in the release channel, only those domains whitelisted under media.getusermedia.screensharing.allowed_domains are actually allowed to use it.

If your domain is on the allowed list, you can use it by using the following keys in the video property.

video: {
    mozMediaSource: "screen",
    mediaSource: "screen"
}

Mozilla hosts a getUserMedia Test Page, on a domain that is white-listed by Firefox Nightly and Firefox Developer Edition. If you use either of these versions of Firefox, you can see it in action. Alternately you could add the domain to the whitelist under about:config and use it in the release and beta channels.

Alexander O'Mara
  • 58,688
  • 18
  • 163
  • 171
  • Thanks! I knew the previous answer would be out of date at some point. Thank you for answering nonetheless. – knight Feb 09 '16 at 13:27
  • How is it possible to get the dialog for window selection? If I bypass permissions, that dialog doesn't display. If I don't bypass them, getUserMedia fails completely for window/screen calls but still works for cameras. – Brad Feb 10 '16 at 06:11
  • @Brad What do you mean by bypassing permissions? – Alexander O'Mara Feb 10 '16 at 06:14
  • @AlexanderO'Mara `about:config` `media.navigator.permission.disabled` set to `true`. – Brad Feb 10 '16 at 06:57
  • @Brad Oh, I see what's happening. Apparently that preference disables the permission dialog entirely, leaving no way to choose what window/screen/application to share (although oddly I did get screen to work once). This is probably a logic bug that's gone unnoticed as the feature isn't officially supported (it's a dangerous feature for browsers). I suppose you could file a bug report with Mozilla about it. – Alexander O'Mara Feb 10 '16 at 07:06
  • @AlexanderO'Mara I notice now that it seems to work sporadically. Most of the time I can capture a screen and a random window. Othertimes, I can capture a screen and window is blank. (That behavior is likely normal... there's probably a 1x1 or hidden window for some application being picked.) But then there are times when I add screen or window capture and my callbacks are never called. If I set `media.navigator.permission.disabled` to `true`, then my error callback is called for `getUserMedia`. – Brad Feb 10 '16 at 15:29
  • @Brad To use the [getUserMedia Test Page](https://mozilla.github.io/webrtc-landing/gum_test.html) in the release version of Firefox, you need to first add `mozilla.github.io,` to the list in `media.getusermedia.screensharing.allowed_domains` under about:config. You also want to make sure `media.navigator.permission.disabled` is set to `false` in order to see the dialog. Then both screen and window sharing should work. This feature is currently in use by [Firefox Hello](https://www.mozilla.org/en-US/firefox/hello/), which also features tab sharing. – jib Feb 11 '16 at 03:11
  • fyi `mozMediaSource` is obsolete and not necessary. – jib Feb 11 '16 at 03:15
  • @jib Hmm, I've done that but it works off and on. I suspect there's something funky going on with Firefox and my graphics card. Firefox often crashes and takes down other OpenGL applications with it. I'll update my graphics drivers and see if I can get a reproducible test case, but I think the problem isn't my code given that restarting firefox a few times resolves the problem. – Brad Feb 11 '16 at 03:58
  • @jib I'm having trouble with the getUserMedia Test Page as well. I went ahead and filed a Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1247792 – Brad Feb 12 '16 at 00:01
  • @jib I have a question somewhat related to this one... along the lines of using the MediaRecorder. If you have a moment, would you take a look? http://stackoverflow.com/questions/35466078/specifying-codecs-with-mediarecorder Sorry to leave a comment on this question... since very few people are using these APIs, I figured cross-linking was the best way to get a hold of someone knowledgeable. – Brad Feb 17 '16 at 19:39
  • Please, just one little help : on localhost, I only have "Don't share" and "Never share", how to get "Always share" on localhost? The "media.navigator.permission.disabled" doesn't work on localhost. – Jose Manuel Abarca Rodríguez May 27 '16 at 22:05
  • @JoseManuelAbarcaRodríguez You might need to clarify your problem a bit. I'm getting the same behavior on `https://localhost` and `https://mozilla.github.io` – Alexander O'Mara May 27 '16 at 22:14
  • The page to show webcam video doesn't work on my local computer because Firefox says "Would you like to share your camera with Unknown origin?", with only two options: "Don't" and "Never". Do I have to upload my code live to get "Always share"? – Jose Manuel Abarca Rodríguez May 27 '16 at 22:19
  • @JoseManuelAbarcaRodríguez I'm not sure which test you are using, but many of these advanced new features with privacy concerns are being made only available over `https`, and not `http` or `file`. Perhaps that is related? – Alexander O'Mara May 27 '16 at 22:21
  • Https? That explains the problem. I will have to find some "https" website to test my webpage. Thanks (+1). – Jose Manuel Abarca Rodríguez May 27 '16 at 22:23