Skip to content

navigator.mediaDevices should have getDisplayMedia #33232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sainnr opened this issue Sep 4, 2019 · 26 comments
Closed

navigator.mediaDevices should have getDisplayMedia #33232

sainnr opened this issue Sep 4, 2019 · 26 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@sainnr
Copy link

sainnr commented Sep 4, 2019

TypeScript Version: Version 3.7.0-dev.20190904, also 3.6.2

Search Terms: web api, media devices, display media, screen capture, navigator, types

Code

const opts = { audio: false, video: true }
navigator.mediaDevices.getDisplayMedia(opts) // TS2339: Property 'getDisplayMedia' does not exist on type 'MediaDevices'.

per lib.dom.d.ts, MediaDevices has getUserMedia but not getDisplayMedia. also: https://github.com/Microsoft/TypeScript/blob/master/src/lib/dom.generated.d.ts#L10201

Expected behavior:
getDisplayMedia should be present on MediaDevices, according to w3c/mediacapture-screen-share#86

Actual behavior:
getDisplayMedia is missing on MediaDevices

Playground Link:
https://www.typescriptlang.org/play/#code/MYewdgzgLgBCAOUIwLwwN4wIYFcAmAliAFwwBmWANhAKYA0MAbgXjSTFAE440wC+AKDBZmAcyxQQnAHQBbGoSwARGs2A0I00TShKCEeJSwBPALIKCWABQIkASiA

Related Issues:

@sandersn sandersn added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Sep 4, 2019
@sandersn sandersn added this to the Backlog milestone Sep 4, 2019
@wiput1999
Copy link

why they still not fix this problem... then how they're using right now

@madabhaviamit
Copy link

Hi Team,

Looks like this issue is not fixed yet, getDisplayMedia is still missing on mediaDevices.
What can be an alternative to use for getting the getDisplayMedia capability? I am using angular 6 in my project..

@LolliDepp
Copy link

still an issue

@wiput1999
Copy link

@LolliDepp Yeah still an issue

@danouche93
Copy link

someone got to fix the issue?

@aponski
Copy link

aponski commented Apr 9, 2020

I'm also having this issue

@aponski
Copy link

aponski commented Apr 19, 2020

Is there a workaround for this error? I'm using Angular 9 and can't build project.

@aponski
Copy link

aponski commented Apr 19, 2020

Workaround to disable Typescript error:
const mediaDevices = navigator.mediaDevices as any;
const stream = await mediaDevices.getDisplayMedia();

@Soflar
Copy link

Soflar commented May 13, 2020

Also having the issue =(

@cqh963852
Copy link

Same issue :(
typescript 3.7.2

@moonrailgun
Copy link

moonrailgun commented May 25, 2020

Still a problem in nightly version.

Maybe you can define it by yourself:

declare global {
  interface MediaDevices {
    getDisplayMedia(constraints?: MediaStreamConstraints): Promise<MediaStream>;
  }

  // if constraints config still lose some prop, you can define it by yourself also
  interface MediaTrackConstraintSet {
    displaySurface?: ConstrainDOMString;
    logicalSurface?: ConstrainBoolean;
    // more....
  }
}

@AlbyGNinja
Copy link

AlbyGNinja commented Jun 4, 2020

Nope, still this problem, also trying workaround..
Right now i'm workaround this adding this line before my getDisplayMedia
// @ts-ignore
Thanks this i can compile successfully, at least

@mivanovaxway
Copy link

Workarounds are bad. getDisplayMedia is complex as it is. We need good definitions.

@riotrah
Copy link

riotrah commented Jul 28, 2020

Seconded - any progress? This API is probably only going to grow in in importance and popularity.

@srivatsav-prayaga
Copy link

Confirm if it's user media or display media guys!

@Akimotorakiyu
Copy link

Still issue!

@michielswaanen
Copy link

@sandersn please have a look at this!

@canvascat
Copy link

Will it be resolved in v4.2.0 ?

@Caesar2011
Copy link

Typescript 4.2.3, 18 months later and still not fixed. It would be so simple!

@mbalc
Copy link

mbalc commented May 11, 2021

a fix for this would have really helped me during my ongoing, new adventure with WebRTC

@SgAkErRu
Copy link

SgAkErRu commented Jul 4, 2021

Typescript 4.3.5, still not fixed. I think it's because getDisplayMedia is W3C Working Draft, but that feature common used and supported by three leading browsers (Firefox, Chrome, Safari), according to Mozilla MDN .

@YongzeYao
Copy link

Plz add definitions for this!

@sandersn sandersn added the Help Wanted You can do this label Jul 30, 2021
@roerohan
Copy link

roerohan commented Aug 2, 2021

Property 'getDisplayMedia' does not exist on type 'MediaDevices'.

Is a fix being made for this?

@akhil-rana
Copy link

akhil-rana commented Aug 28, 2021

Please add definitions for getDisplayMedia. This is being used everywhere and supported by every major browser.

@kim3er
Copy link

kim3er commented Sep 2, 2021

If I understand the process correctly that generates these new types, it looks like getDisplayMedia is on it's way.

microsoft/TypeScript-DOM-lib-generator#992 (comment)

@sandersn
Copy link
Member

sandersn commented Sep 7, 2021

  1. TS 4.4 includes getDisplayMedia
  2. If you can't upgrade to 4.4, you can add a reference to @types/[email protected] (or higher) and remove 'dom' from your 'lib' array in tsconfig.

@sandersn sandersn closed this as completed Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests