Reputation: 28899
I am trying to share user screen and need to use getDisplayMedia
but getting error during project compile time
Property 'getDisplayMedia' does not exist on type 'Navigator'
Here is the code
let stream = await navigator.getDisplayMedia({ video: true })
Package versions are as
Upvotes: 2
Views: 5070
Reputation: 91
If you are in angular you don't getDisplayMedia with navigator or mediaDevices. It shows error on getDisplayMedia. So what you can do to remove the error is.
Declare
nav: any;
then where you have to use getDisplayMedia()
this.nav = navigator;
stream = this.nav.mediaDevices.getDisplayMedia(your content)
Upvotes: 3
Reputation: 28899
In Angular 6+
let stream = await navigator.getDisplayMedia({ video: true })
console.log(stream)
Note: To record the screen in Angular 6+
, you need to enable experimental web platform features
in chrome://flags
until it is launched properly because it is in development and testing mode
see the below image for details:
Upvotes: 2
Reputation: 13371
getDisplayMedia
is no longer available in navigator
. It was moved to navigator.mediaDevices.getDisplayMedia
.
Also make sure you have the typing for the navigator
installed.
Upvotes: 1
Reputation: 222682
According to the documentation you need to use navigator.mediaDevices.getDisplayMedia
The error you are seeing it because there is no property available with navigator
named getDisplayMedia
Upvotes: 3