# Web SDK Screen Sharing not working when Website is opened through Electron App

**URL:** <https://devforum.zoom.us/t/web-sdk-screen-sharing-not-working-when-website-is-opened-through-electron-app/119482>\
**Category:** Meeting SDK\
**Created:** [October 19, 2024, 8:56pm UTC](https://devforum.zoom.us/t/web-sdk-screen-sharing-not-working-when-website-is-opened-through-electron-app/119482 "2024-10-19T20:56:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![samudraganguly002017](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/samudraganguly002017/32/45827_2.png) [@samudraganguly002017](https://devforum.zoom.us/u/samudraganguly002017)\
**Post date:** [October 19, 2024, 8:56pm UTC](https://devforum.zoom.us/t/web-sdk-screen-sharing-not-working-when-website-is-opened-through-electron-app/119482/1 "2024-10-19T20:56:30Z")

</div>

**Meeting SDK Type and Version**  
Latest SDK Version

**Description**  
When I am trying to share my screen, I am getting a dialog:

> No share source content

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/d/1/d190dbcff51564233cd0c35e177411adee1cd38a.png)

However, no error when joined from browser.

**Electron Code:**

_main.js_

```auto
const { app, BrowserWindow, Menu, dialog, session, desktopCapturer, ipcMain } = require('electron');

let mainWindow;

function createWindow() {
    mainWindow = new BrowserWindow({
        width: 800,
        height: 600,
        webPreferences: {
            nodeIntegration: true,
            backgroundThrottling: false,
	    contextIsolation: true,
	    enableRemoteModule: true,
	    preload: `${__dirname}/preload.js`,
	    devTools: false // Disable background throttling
        }
    });

    // Clear cache and load the URL
    session.defaultSession.clearCache().then(() => {
        console.log('Cache cleared');
        mainWindow.loadURL('https://mywebsite.com');
    });

    // Ensure the page is fully loaded
    mainWindow.webContents.on('did-finish-load', () => {
        console.log('Page loaded');
    });

    mainWindow.on('close', (e) => {
        // Prevent the window from closing immediately
        e.preventDefault();

        // Show a confirmation dialog
        const choice = dialog.showMessageBoxSync(mainWindow, {
            type: 'question',
            buttons: ['Yes', 'No'],
            title: 'Confirm',
            message: 'Are you sure you want to quit?'
        });

        // If the user clicks 'Yes', allow the app to close
        if (choice === 0) {
            app.exit(); // Close the app
        }
    });

    // Add a small delay to handle redirects
    mainWindow.webContents.on('did-navigate', () => {
        setTimeout(() => {
            console.log('Redirecting to next page...');
        }, 2000); // Adjust the delay as necessary
    });

    //Menu.setApplicationMenu(null);

    // Disable keyboard shortcuts for Developer Tools (Ctrl+Shift+I or F12)
    mainWindow.webContents.on('before-input-event', (event, input) => {
        if (input.key === 'F12' || (input.control && input.shift && input.key === 'I')) {
            event.preventDefault(); // Disable DevTools shortcuts
        }
    });

    ipcMain.handle('get-sources', async (event) => {
  	const sources = await desktopCapturer.getSources({ types: ['window', 'screen'] });
  	return sources;
    });

    // Open dev tools for debugging (remove this for production)
    // mainWindow.webContents.openDevTools();
}

app.whenReady().then(() => {
    session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
        desktopCapturer.getSources({ types: ['screen'] })
            .then((sources) => {
                console.log("MONSTER: " + sources[0].name);
                callback({ video: sources[0] });
            })
            .catch((error) => { // Changed from error() to catch()
                console.log("ERROR: " + error);
            });
    });
    createWindow();
});

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit();
    }
});

app.on('activate', () => {
    if (BrowserWindow.getAllWindows().length === 0) {
        createWindow();
    }
});

```

_preload.js_

```auto
const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('electronAPI', {
  getSources: () => ipcRenderer.invoke('get-sources'),
});

```

Am I missing anything?

_ **Note** _: console does not show anything.

---

<div class="post-metadata">

**Author:** ![samudraganguly002017](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/samudraganguly002017/32/45827_2.png) [@samudraganguly002017](https://devforum.zoom.us/u/samudraganguly002017)\
**Post date:** [October 20, 2024, 5:23am UTC](https://devforum.zoom.us/t/web-sdk-screen-sharing-not-working-when-website-is-opened-through-electron-app/119482/2 "2024-10-20T05:23:56Z")

</div>

@chunsiong.zoom Will it be possible for you to resolve this issue?
