muaz-khan / getScreenId

getScreenId | Capture Screen on Any Domain! This script is a hack used to support single chrome extension usage on any HTTPs domain.
https://www.webrtc-experiment.com/getScreenId/
MIT License
63 stars 29 forks source link

Problem getting the screen after selecting the window- Screen Share #3

Open ishan501 opened 7 years ago

ishan501 commented 7 years ago

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.

muaz-khan commented 7 years ago

Firefox requires this:

You must publish above addon yourself on Firefox addons store.

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

ishan501 commented 7 years ago

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!

shivangpatel commented 6 years ago

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