getScreenId | Capture Screen on Any Domain!
- Live Demo: https://www.webrtc-experiment.com/getScreenId/
- YouTube video: https://www.youtube.com/watch?v=UHrsfe9RYAQ
- Install this: https://chrome.google.com/webstore/detail/screen-capturing/ajhifddimkapgcifgcodmmfdlknahffk
- Now use below codes on any HTTPs domain.
- Remember, HTTPs is required.
- getScreenId gives you "MediaStream" object; you can share that object with other users using AppRTC demo, SimpleWebRTC or EasyRTC or PeerJs libraries, or any standalone peer-to-peer demo.
- In simple words, you have to use RTCPeerConnection API along with getScreenId to share screen with other users.
npm instll webrtc-screen-capturing
Hacking to use single chrome-extension on any domain!
<!--* This script is a hack used to support single chrome extension usage on any domain. * This script has issues, though.* It uses "postMessage" mechanism which fails to work if someone is using it from inside an <iframe>.* The only solution for such cases is, use WebSockets or external servers to pass "source-ids".-->
You don't need to PUBLISH/deploy your own chrome-extension when using this script!
LocalHost server
node server.js
Nope open: https://localhost:9001/
How to use?
getScreenId
This method allows you get chrome-media-source-id; which can be used to capture screens.
;
Or...
;
getChromeExtensionStatus
This method allows you detect whether chrome extension is installed or not:
;
How it works?
- Your script will make a
postMessage
request togetScreenId.js
getScreenId.js
will connect with chrome-extension using an internal<iframe>
.- That
<iframe>
is loaded from domain:https://www.webrtc-experiment.com/
- That
<iframe>
can connect with chrome-extension. It can send/receivepostMessage
data. - Same
postMessage
API are used to passscreen-id
back to your script.
Custom Parameter
Pass second argument to getScrenId
method:
true
means that capture system audio i.e. speakers[]
array means that capture custom array items
; // capture speakers; // capature only tab; // capature only app's windows; // capature only screen with speakers
Firefox
Deploy extension yourself?
Alternative?
License
getScreenId.js is released under MIT licence . Copyright (c) Muaz Khan.