Problem with sharing Windows app screen with sound in Electron

Hello.

In the Electron application with the React shell that I am working on, I used:

@zoom/videosdk”: “^2.2.0”

My Electron version is “26.1.0”.
In a part of my application, I need to share another application. I want to share that application with sound.
For this, I used the under code.
What happened in this part is that the image is shared but the sound is not. Although I set the code to add sound, this does not happen.

I don’t find any logs or errors related to this issue in the console tab. How can I fix this?

const startZoomShareScreen = async (source_id: string) =>
{

    if(zoomContext.zmClient.current.getMediaStream().isStartShareScreenWithVideoElement())

    {

        await zoomContext.zmClient.current.getMediaStream().startShareScreen(document.createElement('video'),

        {

            sourceId: source_id,

            controls:

            {

                systemAudio: 'include'

            }

        });

    }

}




const appOpenedHandler = async () =>

{

    const retries = 5;

    let appWindow;




    try

    {

        appWindow = await retry(

        async (bail, attempt) =>

        {

            if (isCancelled.current)

            {

                return bail(new Error("Looking for app canceled."));

            }




            logger.info(`Trying to find app window attempt ${attempt}`);

            const sources = await window.electron.desktopCapturer.getSources(

            {

                types: ["window"],

            });




            sources.map((source) =>

            {

                logger.info(`Found desktop capture source with name:${source.name}, ID: ${source.id}`);

            });




            const appWindow = sources.find((source) => source.name.startsWith("My Windows Application"));




            if (!appWindow)

            {

                if (attempt - 1 === retries)

                    return appWindow;




                throw Error("My app window not found.");

            }




            return appWindow;

        },

        { factor: 1, retries },

        );

    }

    catch (error)

    {

        if (error instanceof Error)

        {

            logger.error(error.message);

            return;

        }

    }




    if (!appWindow)

    {

        logger.error("Could not find the app window. This should never happen.");

        return;

    }




    try

    {

        logger.info(`Found app window ID: ${appWindow?.id} name: ${appWindow?.name}`);




        const stream = await navigator.mediaDevices.getUserMedia({

            audio:

            {

                mandatory:

                {

                    chromeMediaSource: "desktop",

                    chromeMediaSourceId: appWindow.id,

                },

            },




            video:

            {

                mandatory:

                {

                    chromeMediaSource: "desktop",

                    chromeMediaSourceId: appWindow.id,

                },

            },

        } as MediaStreamConstraints);




        logger.info(`Got app window stream with id: ${stream?.id}`);




        const videoTrack = stream.getVideoTracks()[0];

        const audioTrack = stream.getAudioTracks()[0];




        logger.info(`Got app window video track with id: ${videoTrack?.id} label: ${videoTrack?.label}`);

        logger.info(`Got app window audio track with id: ${audioTrack?.id} label: ${audioTrack?.label}`);




        setShareStream(stream);

        logger.info(`Published the app window publisher`);




        if (zoomContext.zmClient.current.getMediaStream())

        {

            await startZoomShareScreen(appWindow?.id);




            logger.info("Started publishing application window (with audio).");

        }

        else

        {

            logger.warn("No session exists so cannot publish window.");

        }

    }

    catch (error: unknown)

    {

        if (error instanceof Error)

        {

            logger.error(error.message);

        }

        else

        {

            if (String(error))

            {

                logger.error(error);

            }

            else

            {

                try

                {

                    logger.error(error);

                }

                catch (error: unknown)

                {

                    logger.error("Unknown error happened while trying to log an error related to publish.");

                }

            }

        }

    }

};