This chrome extension simply captures content of your screen. It returns source-id
to callee; and that source-id
can be used as chromeMediaSourceId
in WebRTC applications to capture screen's MediaStream.
List of applications that are using same extension:
- getScreenId.js - a tinny javascript library that be used in any domain, application or WebRTC wrapper library.
- RTCMultiConnection.js - a WebRTC wrapper library providing approximately all possible WebRTC p2p-mesh-based features.
- Screen.js - a screen capturing library along with multi-user p2p screen streaming.
- Pluginfree Screen Sharing - a standalone application, providing multi-user p2p screen streaming in HD format.
It is recommended to use getScreenId.js
to capture screen. In that case, you don't need to publish this chrome extension yourself in Google App Store.
<script src="//cdn.WebRTC-Experiment.com/getScreenId.js"></script>
<video controls autoplay></video>
<script>
getScreenId(function (error, sourceId, screen_constraints) {
navigator.getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia;
navigator.getUserMedia(screen_constraints, function (stream) {
document.querySelector('video').src = URL.createObjectURL(stream);
}, function (error) {
console.error(error);
});
});
</script>
First step: modify allowed-domains
in manifest.json
file:
{
"content_scripts": [ {
"js": [ "content-script.js" ],
"all_frames": true,
"run_at": "document_start",
"matches": ["*://www.domain.com/*"]
}]
}
To test locally, you can add *://localhost:*/*
in the matches
list.
Second step: make ZIP of the directory.
Third step: navigate to Chrome WebStore Developer Dashboard and click Add New Item blue button.
To learn more about how to publish a chrome extension in Google App Store:
Make sure that you added and verified your webpage/domain using Google WebMaster tools. Additional instructions available here.
<!DOCTYPE html>
<html>
<head>
<!-- head; this <link> tag MUST be in <head> section -->
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/your-chrome-extension-id">
</head>
<body>
<!-- body; the button element that is used to invoke inline installation -->
<button onclick="" id="install-button" style="padding: 0;background: none;height: 61px;vertical-align: middle;cursor:pointer;">
<img src="https://www.webrtc-experiment.com/images/btn-install-chrome-extension.png" alt="Add to Chrome">
</button>
<script>
document.querySelector('#inline-install').onclick = function() {
!!navigator.webkitGetUserMedia
&& !!window.chrome
&& !!chrome.webstore
&& !!chrome.webstore.install &&
chrome.webstore.install(
'https://chrome.google.com/webstore/detail/your-chrome-extension-id',
successCallback,
failureCallback
);
};
function successCallback() {
location.reload();
}
function failureCallback(error) {
alert(error);
}
</script>
</body>
</html>
For additional information, click this link.
- Personal Webpage: http://www.muazkhan.com
- Email: [email protected]
- Twitter: https://twitter.com/muazkh and https://twitter.com/WebRTCWeb
- Google+: https://plus.google.com/+WebRTC-Experiment
- Facebook: https://www.facebook.com/WebRTC
Chrome-Extensions are released under MIT licence . Copyright (c) Muaz Khan.