Here, we will develop the angular application for checking microphone is connected or not with the device.
Step 1: Create a new Application
ng new check-microphone
Step 2: Install node_modules
yarn install
Step 3: Install below module
yarn add angular-audio-context
Step 4: Import it in the app.module.ts
import { AudioContextModule } from 'angular-audio-context'; imports: [ AudioContextModule.forRoot('balanced') ],
Step 5: Write below code in a app.component.ts file
checkMicrophone(){ navigator.mediaDevices.getUserMedia({ audio: true }) .then(function (stream) { alert('Mic Is Connected'); }).catch(function () { alert('Mic Is Not Connected'); }); }
Step 6: Write below code in app.component.html file
<button (click)="checkMicrophone();">Check Mic</button>
Step 7: Now Run the project
npm start