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

Streaming media


This recipe covers another interesting feature that can be implemented using the WebRTC stack: streaming prerecorded media from one peer to another one.

Getting ready

We will stream a prerecorded WebM file, so you need to have one. You can download demo WebM files from the Internet. For example, from http://www.webmfiles.org/demo-files/.

In this recipe, we will create two files: an HTML page and a JavaScript library.

Note

This feature doesn't work on the local filesystem. To implement this feature, you need to have a web server where you can place all the application files, and where the application is accessible to the customer.

A signaling server is also necessary for this recipe. You can use the server from Chapter 1, Peer Connections.

How to do it…

Open your text editor, and let's create the HTML page by following the given steps:

  1. Make a simple HTML header:

    <!DOCTYPE html>
    <html>
    <head>
        <title>My WebRTC file media streaming demo</title>
  2. Add some...