Closed supun19 closed 6 years ago
// Enable Screen Sharing
var button = $('#screenShareButton'),
setButton = function (bool) {
button.text(bool ? 'share screen' : 'stop sharing');
};
webrtc.on('localScreenStopped', function () {
setButton(true);
});
setButton(true);
button.click(function () {
if (webrtc.getLocalScreen()) {
webrtc.stopScreenShare();
setButton(true);
} else {
webrtc.shareScreen(function (err) {
if (err) {
setButton(true);
} else {
setButton(false);
}
});
}
});
Note that this only works out of the box in Firefox and over SSL. Chrome needs to be started with certain parameters ( "--enable-usermedia-screen-capturing") or needs to use plugins for screen sharing to work properly.
thank you your reply @cmar0ck
i am using this extension https://github.com/otalk/getScreenMedia
this is a manifest.json
{ "name": "Screensharing Sample", "description": "Screensharing utility sample for getscreenmedia", "version": "0.0.1", "manifest_version": 2, "minimum_chrome_version": "34", "icons": { }, "permissions": [ "desktopCapture" ], "background": { "scripts": ["background.js"] }, "content_scripts": [ { "js": [ "content.js" ], "matches": [ "http://localhost:8000/*" ] }], "externally_connectable": { "matches": [ "http://localhost:8000/*" ] } }
i also get this error
screen share error: HTTPS_REQUIRED Error: NavigatorUserMediaError at module.exports (getscreenmedia.js:11) at WebRTC.LocalMedia.startScreenShare (localmedia.js:148) at SimpleWebRTC.shareScreen (simplewebrtc.js:410) at WebRTCComponent.screenShare (WebRTCComponent.js:333) at HTMLUnknownElement.callCallback (react-dom.development.js:100) at Object.invokeGuardedCallbackDev (react-dom.development.js:138) at Object.invokeGuardedCallback (react-dom.development.js:187) at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:201) at executeDispatch (react-dom.development.js:461) at executeDispatchesInOrder (react-dom.development.js:483)
can you help for fixing this issue
I also enable flag "Allow invalid certificates for resources loaded from localhost." in chrome
You need to use ssl / https (not http). It's also possible that chrome rejects self-signed certs
Thank You @cmar0ck it worked.
could you share screen share sample code with me