diff --git a/src/talk/renderer/AppGetDesktopMediaSource.vue b/src/talk/renderer/AppGetDesktopMediaSource.vue new file mode 100644 index 00000000..ea147f85 --- /dev/null +++ b/src/talk/renderer/AppGetDesktopMediaSource.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/src/talk/renderer/getDesktopMediaSource.js b/src/talk/renderer/getDesktopMediaSource.js new file mode 100644 index 00000000..b4e0683c --- /dev/null +++ b/src/talk/renderer/getDesktopMediaSource.js @@ -0,0 +1,41 @@ +/* + * @copyright Copyright (c) 2024 Grigorii Shartsev + * + * @author Grigorii Shartsev + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import Vue from 'vue' + +import AppGetDesktopMediaSource from './AppGetDesktopMediaSource.vue' + +/** @type {import('vue').ComponentPublicInstance} */ +let appGetDesktopMediaSourceInstance + +/** + * Prompt user to select a desktop media source to share and return the selected sourceId or an empty string if canceled + * + * @return {Promise<{ sourceId: string }>} sourceId of the selected mediaSource or an empty string if canceled + */ +export async function getDesktopMediaSource() { + if (!appGetDesktopMediaSourceInstance) { + const container = document.body.appendChild(document.createElement('div')) + appGetDesktopMediaSourceInstance = new Vue(AppGetDesktopMediaSource).$mount(container) + } + + return appGetDesktopMediaSourceInstance.promptDesktopMediaSource() +} diff --git a/src/talk/renderer/talk.main.js b/src/talk/renderer/talk.main.js index a88384e8..167a59bf 100644 --- a/src/talk/renderer/talk.main.js +++ b/src/talk/renderer/talk.main.js @@ -25,6 +25,7 @@ import './assets/styles.css' import 'regenerator-runtime' // TODO: Why isn't it added on bundling import { init, initTalkHashIntegration } from './init.js' import { setupWebPage } from '../../shared/setupWebPage.js' +import { getDesktopMediaSource } from './getDesktopMediaSource.js' // Initially open the welcome page, if not specified if (!window.location.hash) { @@ -43,3 +44,7 @@ await import('@talk/src/main.js') initTalkHashIntegration(OCA.Talk.instance) await import('./notifications/notifications.store.js') + +window.OCA.Talk.Desktop = { + getDesktopMediaSource, +}