Skip to content

Commit

Permalink
Added Chrome screensharing extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
fancycode committed Jan 20, 2017
1 parent b1c5479 commit d3bc486
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions extensions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains screensharing extensions for various browsers.
7 changes: 7 additions & 0 deletions extensions/chrome/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Screensharing utility for the Nextcloud video calls app

Based on the getScreenMedia example from
https://github.com/HenrikJoreteg/getScreenMedia/tree/master/chrome-extension-sample

Make sure to replace `replace-with-your-hostname` with your actual hostname
in `manifest.json` before installing the extension.
26 changes: 26 additions & 0 deletions extensions/chrome/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* global chrome */

(function() {

/* background page, responsible for actually choosing media */
chrome.runtime.onMessageExternal.addListener(function (message, sender, callback) {
switch(message.type) {
case 'getScreen':
chrome.desktopCapture.chooseDesktopMedia(message.options || ['screen', 'window'],
sender.tab, function (streamid) {
// communicate this string to the app so it can call getUserMedia with it
message.type = 'gotScreen';
message.sourceId = streamid;
callback(message);
return false;
});
return true; // retain callback for chooseDesktopMedia result
case 'cancelGetScreen':
chrome.desktopCapture.cancelChooseDesktopMedia(message.request);
message.type = 'canceledGetScreen';
callback(message);
return false; //dispose callback
}
});

})();
7 changes: 7 additions & 0 deletions extensions/chrome/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* global chrome */

(function() {

sessionStorage.getScreenMediaJSExtensionId = chrome.runtime.id;

})();
24 changes: 24 additions & 0 deletions extensions/chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Nextcloud Screensharing",
"description": "Screensharing utility for the Nextcloud video calls app.",
"version": "0.0.1",
"manifest_version": 2,
"minimum_chrome_version": "34",
"icons": {
},
"permissions": [
"desktopCapture"
],
"background": {
"scripts": ["background.js"]
},
"content_scripts": [ {
"js": [ "content.js" ],
"matches": [ "https://replace-with-your-hostname/*" ]
}],
"externally_connectable": {
"matches": [
"https://replace-with-your-hostname/*"
]
}
}

0 comments on commit d3bc486

Please sign in to comment.