我知道如何捕获网页,但我想问如何捕获桌面或桌面中的其他应用程序?如果有办法突出显示屏幕的某些部分。就像 html2canvas 对网页所做的那样,我们可以使用 HTML/JS 中的浏览器应用程序为桌面应用程序做一些事情吗?
对的,这是可能的!
但据我所知仅适用于 Firefox 和 Chrome(我使用 Chrome)。谢谢屏幕截图和网络RTC。有关 WebRTC 的更多信息
我使用了一个名为RTC多重连接这是非常容易使用的,但你应该能够在不使用任何库的情况下做到这一点。
在这里,只是给您一个起点:
// 1. Create the connection Objekt
var connection = new RTCMultiConnection();
// 2. Activate screen, which is the whole monitor, not only the browser window!
connection.session = {
screen: true,
data: false,
oneway: true
};
// 3. Create the callback for the stream
connection.onstream = function(event) {
// Make something with the event
// event.stream contains the stream, event.mediaElement the media
// I used event.mediaElement as parameter to draw the frage into an canvas; via context2d.drawImage(event.mediaElement, ...)
// Then I create an base64 String via canvas.toDataURL("image/png") and
// Don't forget to stop the stream if you just want to have one single image
};
// 4. Start Desktop Sharing
connection.open({
// you could register a onMediaCaptured callback here
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)