Files
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00
..
2026-11-17 16:15:01 -05:00
2026-11-17 16:15:01 -05:00

getDisplayMedia demo

How to use?

var displayMediaStreamConstraints = {
    video: true // currently you need to set {true} on Chrome
};

if (navigator.mediaDevices.getDisplayMedia) {
    navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error);
} else {
    navigator.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error);
}

Edge

var displayMediaStreamConstraints = {
    video: {
        width: screen.width,
        height: screen.height,
        displaySurface: 'monitor', // monitor or window or application or browser
        logicalSurface: true,
        frameRate: 30,
        aspectRatio: 1.77,
        cursor: 'always', // always or never or motion
    }
};

if (navigator.mediaDevices.getDisplayMedia) {
    navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error);
} else {
    navigator.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error);
}

cursor

cursor accepts three values:

  1. always
  2. never
  3. motion

displaySurface

displaySurface accepts four values:

  1. monitor
  2. window
  3. application
  4. browser

logicalSurface

logicalSurface accepts boolean true or false values.

Spec

Disclaimer

There is no warranty, expressed or implied, associated with this product. Use at your own risk.

License

All WebRTC Experiments are released under MIT license . Copyright (c) Muaz Khan.