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
WebRTC Cookbook

WebRTC Cookbook

By : Andrii Sergiienko
5 (1)
close
close
WebRTC Cookbook

WebRTC Cookbook

5 (1)
By: Andrii 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

Using the opacity filter


In this recipe, we will cover how to use the opacity filter. You will probably rarely use it, but it can be used for implementing interesting features, such as picture in picture.

How to do it…

Follow these steps:

  1. Add a control element to the main web page of your application—using this object we will control the video's opacity:

    Opacity
    <input type="range" oninput="changeOpacity(this.valueAsNumber);" value="1" step="0.1" min="0" max="1">
  2. Add an appropriate JavaScript function:

    function changeOpacity(val) {
      var v = document.getElementById("localVideo");
      v.style.webkitFilter="opacity(" + val + ")";
    };

    Here localVideo is the ID property of the HTML video tag for the local video playback.

  3. Navigate your web browser to the web page. You will first see an unprocessed video from the web camera, with no filter applied. The following screenshot depicts this stage:

  4. On the left-hand side of the page, you can see a control described as Opacity. Try to move it to the left and...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
WebRTC Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

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

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon