mirror of https://github.com/dani/vroom.git
Since Chrome 34, a new API for screen sharing is available (the previous one using the flag will probably be deprecated soon) This commit adds: - Source of a simple Chrome extension to use this new API (which is a perfect copy of the sample extension given by &yet here: https://github.com/HenrikJoreteg/getScreenMedia - Adapt help page - New modal dialog to prompt user to install the extension from Google Web Store - Better error messages if you can't share your screen Should fix #7master
parent
ab4126d8a9
commit
536143bdf0
10 changed files with 105 additions and 6 deletions
@ -0,0 +1,25 @@ |
|||||||
|
/* background page, responsible for actually choosing media */ |
||||||
|
chrome.runtime.onConnect.addListener(function (channel) { |
||||||
|
channel.onMessage.addListener(function (message) { |
||||||
|
switch(message.type) { |
||||||
|
case 'getScreen': |
||||||
|
var pending = chrome.desktopCapture.chooseDesktopMedia(message.options || ['screen', 'window'],
|
||||||
|
channel.sender.tab, function (streamid) { |
||||||
|
// communicate this string to the app so it can call getUserMedia with it
|
||||||
|
message.type = 'gotScreen'; |
||||||
|
message.sourceId = streamid; |
||||||
|
channel.postMessage(message); |
||||||
|
}); |
||||||
|
// let the app know that it can cancel the timeout
|
||||||
|
message.type = 'getScreenPending'; |
||||||
|
message.request = pending; |
||||||
|
channel.postMessage(message); |
||||||
|
break; |
||||||
|
case 'cancelGetScreen': |
||||||
|
chrome.desktopCapture.cancelChooseDesktopMedia(message.request); |
||||||
|
message.type = 'canceledGetScreen'; |
||||||
|
channel.postMessage(message); |
||||||
|
break; |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
@ -0,0 +1,14 @@ |
|||||||
|
/* the chrome content script which can listen to the page dom events */ |
||||||
|
var channel = chrome.runtime.connect(); |
||||||
|
channel.onMessage.addListener(function (message) { |
||||||
|
console.log('channel message', message); |
||||||
|
window.postMessage(message, '*'); |
||||||
|
}); |
||||||
|
|
||||||
|
window.addEventListener('message', function (event) { |
||||||
|
if (event.source != window) |
||||||
|
return; |
||||||
|
if (!event.data && (event.data.type == 'getScreen' || event.data.type == 'cancelGetScreen')) |
||||||
|
return; |
||||||
|
channel.postMessage(event.data); |
||||||
|
}); |
@ -0,0 +1,19 @@ |
|||||||
|
{ |
||||||
|
"name": "Screen sharing for VROOM", |
||||||
|
"description": "Allow screen sharing in the VROOM WebRTC visio conference 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://*/*"] |
||||||
|
}] |
||||||
|
} |
Loading…
Reference in new issue