In my web page, there is a screen sharing stream, the following are the parameters:
{
audio: false,
video: mandatory {
chromeMediaSource: 'desktop',
chromeMediaSourceId: IM.screenSourceId
...
}
...
}
My Chrome extension contains the following code in the background script:
desktop_id = chrome.desktopCapture.chooseDesktopMedia (session, port.sender.tab, onAccessApproved);
When click the "Cancel" button on the page, the listener function in the background script is triggered:
chrome.desktopCapture.cancelChooseDesktopMedia (desktop_id);
In chrome://extensions of console.log to see desktop_id really is an integer value of 1.
But it seems does not work, I tried many Chrome versions but it still does not work, what should I do to cancel the screen sharing?
chrome.desktopCapture.cancelChooseDesktopMediacloses the chooser dialog if it is still open. It does NOT stop the media stream after the user has choosen a target for recording.If you want to stop recording the screen, call the
.stop()method of the media stream instead. E.g.