window.dos.getSources({ types: ['window', 'screen'] }).then(async (sources: any) => {
console.log(sources)
for (let key in sources){
if(sources[key].name.indexOf("微信")){
let sourceId = ''; // 所选择的屏幕或窗口 sourceId
navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: sources[key].id,
maxWidth: window.screen.width,
maxHeight: window.screen.height,
}
}
}).then((stream)=>{
console.log(stream)
video.value.srcObject = stream;
video.value.play();
// createRecorder(stream)
})
}
}
})
navigator.mediaDevices.getUserMedia 抓取指定窗口
最新推荐文章于 2024-07-31 17:10:06 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)