[Fixed] navigator.getDisplayMedia is not a function in angular 6

Issue

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

  1. Node v10.14.2
  2. NPM v6.5.0
  3. @angular/cli v6.1.5

Solution

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:

enter image description here

Leave a Reply

(*) Required, Your email will not be published