Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying WebRTC Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
WebRTC Cookbook

WebRTC Cookbook

By : Sergiienko
5 (1)
close
close
WebRTC Cookbook

WebRTC Cookbook

5 (1)
By: Sergiienko

Overview of this book

If you are a JavaScript developer with a basic knowledge of WebRTC and software development, but want to explore how to use it in more depth, this book is for you.
Table of Contents (10 chapters)
close
close
9
Index

Muting a microphone


Usually, voice calling software has a microphone muting feature. So, you can enable or disable your microphone during the call, deciding whether the remote peer should hear your voice or not. In this recipe, we will implement such a feature for a WebRTC application.

Getting ready

For this example, you don't need any preliminary specific steps. Use your development environment as you usually do.

How to do it…

Follow these steps:

  1. For this feature, you need to add a button element to your HTML page. This button will enable or disable the microphone:

    <button id="mute_btn" onclick="muteBtnClick()">Mute Mic</button>
  2. You also need to set up a handler for the onclick event of the element—it will do the actual work. The following code is an example of such a handler:

    function muteBtnClick() {
  3. We will update our button with the microphone state, so we need to get the button ID:

         var btn = document.getElementById("mute_btn");
  4. Before we can decide whether we want to mute or...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY