Book Image

WebRTC Cookbook

By : Andrii Sergiienko
Book Image

WebRTC Cookbook

By: Andrii Sergiienko

Overview of this book

Table of Contents (15 chapters)
WebRTC Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Pausing a video


If you're participating in a video conference call, you might want to temporarily switch your video camera off and take a pause. During this time, your remote peer shouldn't see an image from your camera. In most videoconferencing software, you can enable or disable your camera during the call. In this recipe, we will implement this feature for a WebRTC application.

Getting ready

For this recipe, you don't need any specific preparations. Just create a basic conferencing WebRTC application.

How to do it…

Perform the following steps:

  1. We need to add a Pause Video button to the application's web page:

    <button id="pause_video_btn" onclick="pauseVideoBtnClick()">Pause Video</button>
  2. You also should set up a handler for the onclick event of the button:

    function pauseVideoBtnClick() {
  3. We will update our button with the video stream state (whether it is paused or not), so we need to get the button ID:

         var btn = document.getElementById("pause_video_btn");
  4. Before we decide whether...