mirror of
https://github.com/dani/vroom.git
synced 2024-07-06 01:58:38 +02:00
536143bdf0
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
26 lines
1.1 KiB
JavaScript
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;
|
|
}
|
|
});
|
|
});
|