Added video support
This commit is contained in:
parent
d62722ce53
commit
c4f1e4d8c0
@ -2,9 +2,9 @@
|
||||
const globalConnnection = Symbol("grab-canvas-connection")
|
||||
|
||||
const currentScriptSrc = document.currentScript.src;
|
||||
const canvas = document.querySelector("canvas");
|
||||
const sourceElt = document.querySelector("canvas,video");
|
||||
|
||||
if(!canvas){
|
||||
if(!sourceElt){
|
||||
console.error("No canvas found on this page")
|
||||
}
|
||||
|
||||
@ -22,7 +22,12 @@
|
||||
const allCandidatesCollected = new Promise(res =>
|
||||
conn.addEventListener("icecandidate", e => e.candidate == null && res() ))
|
||||
|
||||
const canvasStream = canvas.captureStream()
|
||||
let captureFn = sourceElt.captureStream;
|
||||
if(!captureFn){
|
||||
captureFn = sourceElt.mozCaptureStream;
|
||||
}
|
||||
|
||||
const canvasStream = captureFn()
|
||||
const canvasStreamTracks = canvasStream.getVideoTracks()
|
||||
if(canvasStreamTracks.length > 0){
|
||||
conn.addTrack(canvasStreamTracks[0], canvasStream)
|
||||
|
Loading…
Reference in New Issue
Block a user