I am currently developing a .Net Core/Angular 8 application in Visual Studio.
Within the Angular (ClientApp) section of my project, I have TypeScript 3.5.3 located in node_modules, which includes the following definition in lib.dom.d.ts
:
interface NavigatorUserMedia {
readonly mediaDevices: MediaDevices;
getDisplayMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
getUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
}
I attempted to call navigator.getDisplayMedia(...)
, but encountered a redline indicating that getDisplayMedia
is not a function of navigator.
Upon further investigation by clicking "Go To Definition" on navigator
, I was directed to the TypeScript defined in
C:\Program Files (x86)\Microsoft SDKs\TypeScript
, which appears to be TypeScript 3.8.3. This version also matches the "TypeScript Version" specified in Project Properties > TypeScript Build. However, upon inspecting the lib.dom.d.ts
file, no presence of the getDisplayMedia function can be found.
To resolve this issue, I tried downloading TypeScript 3.5.3 via NuGet, which successfully updated the TypeScript version in Project Properties > TypeScript Build and resolved the redline error during building the project. Despite this, when trying to execute the function, an error is thrown in the browser console stating that getDisplayMedia is not a function of navigator...
This situation has left me puzzled as to what may be causing this discrepancy.
Please note: I am aware that getDisplayMedia should be accessed through MediaDevices. However, after reviewing the lib.dom.d.ts
for both TypeScript versions 3.5.3 and 3.8.3, it seems that MediaDevices does not include the getDisplayMedia method.