getScreenId icon indicating copy to clipboard operation
getScreenId copied to clipboard

Problem getting the screen after selecting the window- Screen Share

Open ishan501 opened this issue 7 years ago • 3 comments

I'm trying to implement the screen share functionality in Firefox. I've tried implementing the extension as you said but that didn't work. Then I came to know that I can do that without the extension.

I wrote your code which is in "capture-screen" onclick event. But, I can select the window(as in your demo) but then I can not see the shared screen.

This is what I do in my JS file in onclick event:

`getScreenId(function(error, sourceId, screen_constraints) {

                    if (IsAndroidChrome) {
                        screen_constraints = {
                            mandatory: {
                                chromeMediaSource: 'screen'
                            },
                            optional: []
                        };
                        
                        screen_constraints = {
                            video: screen_constraints
                        };

                        error = null;
                    }

                    if(error == 'not-installed') {
                      alert('Please install Chrome extension. See the link below.');
                      return;
                    }

                    if(error == 'installed-disabled') {
                      alert('Please install or enable Chrome extension. Please check "chrome://extensions" page.');
                      return;
                    }

                    if(error == 'permission-denied') {
                      alert('Please make sure you are using HTTPs. Because HTTPs is required.');
                      return;
                    }

                    console.info('getScreenId callback \n(error, sourceId, screen_constraints) =>\n', error, sourceId, screen_constraints);

                    navigator.getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia;
                    navigator.getUserMedia(screen_constraints, function(stream) {

                        document.querySelector('video').src = URL.createObjectURL(stream);

                        stream.oninactive = stream.onended = function() {
                            document.querySelector('video').src = null;
                        };

                    }, function(error) {
                        console.error('getScreenId error', error);

                        alert('Failed to capture your screen. Please check Chrome console logs for further information.');
                    });
                });`

I have also getScreenId.js as you stated.

Kindly tell me what I'm doing wrong.

Thank you.

ishan501 avatar Jun 13 '17 12:06 ishan501

Firefox requires this:

  • https://github.com/muaz-khan/Firefox-Extensions/tree/master/enable-screen-capturing

You must publish above addon yourself on Firefox addons store.

Otherwise drop "XPI" file on Firefox address-bar/tool-bar.

muaz-khan avatar Jun 13 '17 14:06 muaz-khan

But the demo on your site works without the extension.

This is what I get when I try to share the screen.

dd

But after selecting the window it doesn't display anything!

ishan501 avatar Jun 14 '17 11:06 ishan501

@ishan501 : you need to test it with https. It's a working fine with firefox.

shivangpatel avatar Feb 07 '18 08:02 shivangpatel