Skip to content

getDisplayMedia in headless #6460

@ldenoue

Description

@ldenoue

I would like to record the current page using getDisplayMedia().

It works now in headful, not headless.
I launch the browser using these args:

browser = await playwright.launch({
		headless:**false**,
		ignoreHTTPSErrors:true,
		args: [
      '--enable-experimental-web-platform-features',
      '--disable-infobars',
      '--enable-usermedia-screen-capturing',
      '--allow-http-screen-capture',
      '--auto-select-desktop-capture-source=**MYPAGETITLE**',
      '--ignore-certificate-errors',
      '--no-sandbox',
      '--autoplay-policy=no-user-gesture-required',
      '--disable-gpu',
      '--hide-scrollbars'
    ],
	});

and inside my web page loaded by the browser, I can now use

canvasStream = await navigator.mediaDevices.getDisplayMedia();

and I indeed get the stream of the tab.

However, it fails when headless = true;

Do you think others might benefit from this as well?
I believe that running headless is much easier since it doesn't require us running a virtual display (e.g. xvfb).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions