feat: add desktopCapturer.getMediaSourceIdForWebContents() to get stream source id from web contents (#22701)
* feat: add desktopCapturer.getMediaSourceIdForWebContents() to get stream source id from web contents * Cleanup from #22701 PR comments
This commit is contained in:
parent
dc72f74020
commit
204f001c5d
9 changed files with 178 additions and 2 deletions
|
@ -130,6 +130,27 @@ desktopCapturer.getSources({ types: ['window', 'screen'] }).then(sources => {
|
|||
}
|
||||
})
|
||||
|
||||
desktopCapturer.getMediaSourceIdForWebContents(remote.getCurrentWebContents().id).then(mediaSourceId => {
|
||||
(navigator as any).webkitGetUserMedia({
|
||||
audio: {
|
||||
mandatory: {
|
||||
chromeMediaSource: 'tab',
|
||||
chromeMediaSourceId: mediaSourceId
|
||||
}
|
||||
},
|
||||
video: {
|
||||
mandatory: {
|
||||
chromeMediaSource: 'tab',
|
||||
chromeMediaSourceId: mediaSourceId,
|
||||
minWidth: 1280,
|
||||
maxWidth: 1280,
|
||||
minHeight: 720,
|
||||
maxHeight: 720
|
||||
}
|
||||
}
|
||||
}, gotStream, getUserMediaError)
|
||||
})
|
||||
|
||||
function gotStream (stream: any) {
|
||||
(document.querySelector('video') as HTMLVideoElement).src = URL.createObjectURL(stream)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue