Jack Hudzenko
Jack Hudzenko

Reputation: 167

How to include webrtc adapter js into Angular5 app

I need to include webrtc-adapter to my Angular 5 app.

What I need to do besides: npm install webrtc-adapter ?

Do I need to make any additional imports?

Upvotes: 6

Views: 6280

Answers (2)

Herman Fransen
Herman Fransen

Reputation: 2210

Include import 'webrtc-adapter'; in every component or service that uses WebRTC.

Also you need to import two zone.js patches:

// rtc peer connection patch
import 'zone.js/dist/webapis-rtc-peer-connection';
// getUserMedia patch
import 'zone.js/dist/zone-patch-user-media';

If you are using angular-cli you should add these lines in polyfills.ts after import 'zone.js/dist/zone'; that's already in this file.

Upvotes: 5

vardius
vardius

Reputation: 6546

As you said you have to install int via npm npm install webrtc-adapter, then you need to include it in your index.js (or other main entry file) simply by doing:

import "webrtc-adapter";

at the top of it.

If you are using webpack instead of importing it you could add this to your webpack config as follow:

  entry: {
    application: "src/index",
    vendor: [
      "webrtc-adapter"
    ]
  },

Here are some examples how I am doing it in my projects:

For an easy abstraction layer of WebRTC I recommend using peer-data

Upvotes: 5

Related Questions