From d9ca0cbebd85f11ef2517411559ceb00895400d0 Mon Sep 17 00:00:00 2001 From: Gautam Singh <5769869+gautamsi@users.noreply.github.com> Date: Wed, 27 May 2020 04:56:31 +0530 Subject: Update Skype with screen sharing (#170) Co-authored-by: Gautam Singh --- all.json | 4 +-- archives/skype.tar.gz | Bin 73228 -> 74347 bytes uncompressed/skype/package.json | 2 +- uncompressed/skype/service.css | 61 ++++++++++++++++++++++++++++++++++++++ uncompressed/skype/webview.js | 64 ++++++++++++++++++++++++++++++++++++---- 5 files changed, 123 insertions(+), 8 deletions(-) diff --git a/all.json b/all.json index c463930..b76b263 100644 --- a/all.json +++ b/all.json @@ -771,10 +771,10 @@ }, { "author": "Stefan Malzner ", - "featured": true, + "featured": false, "id": "skype", "name": "Skype", - "version": "1.3.0", + "version": "1.4.0", "icons": { "png": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/skype/icon.png", "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/skype/icon.svg" diff --git a/archives/skype.tar.gz b/archives/skype.tar.gz index 5d316d0..5c6a5fd 100644 Binary files a/archives/skype.tar.gz and b/archives/skype.tar.gz differ diff --git a/uncompressed/skype/package.json b/uncompressed/skype/package.json index b61e4a3..7437d65 100644 --- a/uncompressed/skype/package.json +++ b/uncompressed/skype/package.json @@ -1,7 +1,7 @@ { "id": "skype", "name": "Skype", - "version": "1.3.0", + "version": "1.4.0", "description": "Skype", "main": "index.js", "author": "Stefan Malzner ", diff --git a/uncompressed/skype/service.css b/uncompressed/skype/service.css index 80ef7da..543076f 100644 --- a/uncompressed/skype/service.css +++ b/uncompressed/skype/service.css @@ -1,3 +1,64 @@ #footer { display: none; } +.desktop-capturer-selection { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100vh; + background: rgba(30,30,30,.75); + color: #fff; + z-index: 10000000; + display: flex; + align-items: center; + justify-content: center; +} +.desktop-capturer-selection__scroller { + width: 100%; + max-height: 100vh; + overflow-y: auto; +} +.desktop-capturer-selection__list { + max-width: calc(100% - 100px); + margin: 50px; + padding: 0; + display: flex; + flex-wrap: wrap; + list-style: none; + overflow: hidden; + justify-content: center; +} +.desktop-capturer-selection__item { + display: flex; + margin: 4px; +} +.desktop-capturer-selection__btn { + display: flex; + flex-direction: column; + align-items: stretch; + width: 145px; + margin: 0; + border: 0; + border-radius: 3px; + padding: 4px; + color: #fff; + background: #252626; + text-align: left; + transition: background-color .15s, box-shadow .15s; +} +.desktop-capturer-selection__btn:hover, +.desktop-capturer-selection__btn:focus { + background: rgba(98,100,167,.8); +} +.desktop-capturer-selection__thumbnail { + width: 100%; + height: 81px; + object-fit: cover; +} +.desktop-capturer-selection__name { + margin: 6px 0 6px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} \ No newline at end of file diff --git a/uncompressed/skype/webview.js b/uncompressed/skype/webview.js index 12ad2a8..63f445c 100644 --- a/uncompressed/skype/webview.js +++ b/uncompressed/skype/webview.js @@ -1,10 +1,63 @@ "use strict"; -var _electron = require("electron"); +const { desktopCapturer, remote: { BrowserWindow } } = require("electron"); +const path = require('path'); -const { - BrowserWindow -} = _electron.remote; +window.navigator.mediaDevices.getDisplayMedia = () => { + return new Promise(async (resolve, reject) => { + try { + const sources = await desktopCapturer.getSources({ types: ['screen', 'window'] }); + + const selectionElem = document.createElement('div'); + selectionElem.classList = 'desktop-capturer-selection'; + selectionElem.innerHTML = ` +
+
    + ${sources.map(({ id, name, thumbnail, display_id, appIcon }) => ` +
  • + +
  • + `).join('')} +
+
+ `; + document.body.appendChild(selectionElem); + + document.querySelectorAll('.desktop-capturer-selection__btn') + .forEach(button => { + button.addEventListener('click', async () => { + try { + const id = button.getAttribute('data-id'); + const source = sources.find(source => source.id === id); + if (!source) { + throw new Error(`Source with id ${id} does not exist`); + } + + const stream = await window.navigator.mediaDevices.getUserMedia({ + audio: false, + video: { + mandatory: { + chromeMediaSource: 'desktop', + chromeMediaSourceId: source.id + } + } + }); + resolve(stream); + + selectionElem.remove(); + } catch (err) { + reject(err); + } + }); + }); + } catch (err) { + reject(err); + } + }) +} module.exports = (Franz, settings) => { const getMessages = function getMessages() { @@ -27,6 +80,7 @@ module.exports = (Franz, settings) => { Franz.setBadge(count); }; + Franz.injectCSS(path.join(__dirname, 'service.css')); Franz.loop(getMessages); document.addEventListener('click', event => { const link = event.target.closest('a[href^="http"]'); @@ -55,4 +109,4 @@ module.exports = (Franz, settings) => { } } }, true); -}; \ No newline at end of file +}; -- cgit v1.2.3-70-g09d2