MediaSFU Shared
    Preparing search index...

    Function produceMedia

    • Publish any MediaStream to the room — not just the camera or microphone.

      clickVideo / clickAudio call getUserMedia internally, so they can only ever publish a real device. Anything else — a <canvas> capture, a <video> element playing a file, a Web Audio destination, a processed or synthesised track, a virtual camera — previously required monkey-patching navigator.mediaDevices.getUserMedia around the call, which is racy and leaks if the control throws. This publishes your stream directly.

      The stream stays yours: stop its tracks when you are done, or call stopProducing to tear the producer down first.

      Parameters

      Returns Promise<HeadlessActionResult>

      import { produceMedia } from 'mediasfu-shared';

      const canvas = document.querySelector('canvas')!;
      const stream = canvas.captureStream(30);
      await produceMedia({ parameters, stream, kind: 'video' });
      const el = document.querySelector('video')!;
      const stream = (el as any).captureStream();
      await produceMedia({ parameters, stream, kind: 'video' });
      await produceMedia({ parameters, stream, kind: 'audio' });