I use HTMLCanvasElement.captureStream()
to get a MediaStream
and pass it to a MediaRecorder
to write it to a .webm file.
According to mdn, MediaStream
s retrieved from navigator.mediaDevices.getDisplayMedia()
can have an option specified to also capture the cursor. This is done by passing in a dictionary {cursor: 'always'}
to either the .getDisplayMedia()
method, or MediaStreamTrack.applyConstraints()
methods.
Is there a way to capture the cursor for MediaStream
s from a HTMLCanvasElement
?
Here's a simplified reproduction example on JSFiddle; make sure to allow the popup.
The relevant lines are duplicated below:
let canvas = document.querySelector('canvas');
let stream = canvas.captureStream(20);
let recorder = new MediaRecorder(stream, {mimeType: 'video/webm'});
I've also tried stream.getTracks()[0].applyConstraints({cursor: 'always'})
to no avail.