1
0
mirror of https://github.com/dani/vroom.git synced 2024-06-01 21:11:41 +02:00
vroom/chrome-extension/background.js
Daniel Berteaud 536143bdf0 Update screen sharing
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 #7
2014-05-01 21:35:07 +02:00

26 lines
1.1 KiB
JavaScript

/* 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;
}
});
});