Screen Capture

navigator.mediaDevices.getDisplayMedia({ video: { displaySurface: 'browser' }, audio: true }) returns a stream of the screen, window or tab the user picks in the browser's dialog; displaySurface only suggests a default. Call it from a click handler (otherwise it throws InvalidStateError); it works on desktop browsers only. Show, record or send the stream over WebRTC (WebRTC Video Channel), and handle the track's ended event, fired when the user clicks "Stop sharing". Audio capture, preferCurrentTab and CaptureController are Chromium-only. Set track.contentHint = 'text' when sharing slides or code to keep edges sharp.