I would like to capture a stream from a Konva Stage.
Before I used regular <canvas ref={canvasRef} />
. After let canvas = canvasRef.current
I was able to capture a stream with let mediaStream: MediaStream = canvas.captureStream(30)
.
Does anyone know how I can achieve the same result using konva-react?
I already tried <Stage ref={stageRef}>...</Stage>
and then let canvas = stageRef.current.getStage().toCanvas()
, but apparently it doesn’t work.
ps. I null-checked before ref.current
, so neither canvasRef
nor stageRef
can be null
Thanks for your help!
On konva, Stage
doesn’t have its own canvas. But a Layer
have it.
<Layer ref={layerRef}>...</Layer>
const canvas = layerRef.current.getNativeCanvasElement();
const mediaStream = canvas.captureStream(30)