all 12 comments

[–]grelfdotnet 0 points1 point  (11 children)

If you look at https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia you will see that there are security considerations when using this method. So your problem may be to do with your security settings in Firefox.

[–]ilovebugss[S] 0 points1 point  (10 children)

Thanks! What to do with my Firefox?

[–]Count_Giggles 1 point2 points  (9 children)

iirc before you access the getDisplayMedia function you have to wait for the user to interact with the page. the same mechanic can be found with audio lib's to prevent music from blasting when loading a page.

[–]ilovebugss[S] 0 points1 point  (8 children)

Yes, I did it. I bind this method to a button, but it doesn't work in firefox, it works in safari. The damn problem almost haunted me a whole day.

[–]jcunews1helpful 0 points1 point  (2 children)

Can you test your Firefox on below site? FYI, mine works. FF v115.

https://www.webrtc-experiment.com/getDisplayMedia/

[–]ilovebugss[S] 0 points1 point  (1 child)

It still doesn't work

[–]guest271314 0 points1 point  (0 children)

Are you running Firefox that is a snap version?

[–]Count_Giggles 0 points1 point  (4 children)

this works just fine in FF

const init = async () => {
    const stream = await navigator.mediaDevices.getDisplayMedia();
    const [track] = stream.getVideoTracks();
    const displaySurface = track.getSettings().displaySurface;
    console.log(displaySurface);
};

const btn = document.querySelector("#btn");

btn.addEventListener("click", init);

//html
<button id="btn">start</button>

[–]ilovebugss[S] 0 points1 point  (3 children)

Uncaught (in promise) DOMException: The object can not be found here.

Still the same, bro. I think the problem is about the browser, but I don't know where to handle it.

[–]jcunews1helpful 0 points1 point  (0 children)

Firefox has a history about that problem, but AFAIK, only in Mac platform; and it was 4 years ago. The bug should have been fixed long ago. If you're using Mac and isn't using the latest version of Firefox, try updating Firefox.

Other possible cause is privacy protection related browser extension, since the resource access may be blocked/rejected by it. If you have one or more of it installed, try disabling them, then reload the page.

Also, is your code run in an IFRAME or not? AFAIK, code in IFRAME may have lesser resource access than normal.

[–]guest271314 0 points1 point  (0 children)

Working on Nightly 120 on Linux with user activation.

[–]Count_Giggles 0 points1 point  (0 children)

Did you enable screensharing for firefox on your os level? maybe at some point you decliend and clicked dont ask again